helix
helix copied to clipboard
LSP Autocompletion does not insert, it overwrites
Summary
Helix
Neovim
Not only does Helix wrongly overwrite width it is also one character short of the end so when immediately typing . it becomes rectangl.e
Reproduction Steps
na
Helix log
na
Platform
Linux
Terminal Emulator
KItty
Helix Version
helix 22.08.1 (418a622d)
pub struct Rectangle {
pub width: usize,
pub height: usize,
pub position: Point2d,
}
fn draw_rectangle(
rectangle: &Rectangle,
content: &style::StyledContent<String>,
stdout: &Stdout,
) -> Result<()> {
for y in 0..width {
for x in 0..rectangle.height {
if (y == 0 || y == rectangle.width - 1) || (x == 0 || x == rectangle.height - 1) {
draw_content(
stdout,
Point2d {
x: rectangle.position.x + y,
y: rectangle.position.y + x,
},
content,
)?;
}
}
}
Ok(())
}
I think this is fixed by #1819
This is actually not a bug at all but rather a missing feature in helix. LSP allows two of operation: either insert text at the cursor and keep the rest of the word or replace the entire word.
The LSP spec let's the editor decide here and suggests a config option. Both VSCode and nvim default to inserting but offer an option to replace instead. See https://github.com/helix-editor/helix/blob/927fa112ec049e5f40309ffdd57c314897e18bbc/helix-term/src/ui/completion.rs#L120
@pascalkuthe I see you are looking at the LSP at the moment with https://github.com/helix-editor/helix/pull/5711 , can you do anything about this issue? In my experience replace behaves more like a bug than a missing feature:
- Do you know why Helix is using replace rather than insert? What is the advantage?
- Why not just switch it to act like VSCode and Nvim?
@the-mikedavis What do you think?
It's just a missing config option. Both VSCode and nvim can be configured to act the same way as helix and the LSP standard specifically acommedatde both options. It's just a case of helix having a different default.
As I said in #5676 I also prefer insert as the default behavior. Not sure what @archseer thinks about changing the default.
I will look into adding a config option. I am travelling this weekend but I can look I to this next week
#5728 adds the option I described (and fixes some other completion related things). I changed the default in that PR and laid out why I think it's a better/more consistent default.