helix icon indicating copy to clipboard operation
helix copied to clipboard

LSP Autocompletion does not insert, it overwrites

Open David-Else opened this issue 3 years ago • 2 comments

Summary

Helix

helix.webm

Neovim

neovim.webm

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(())
}

David-Else avatar Oct 20 '22 09:10 David-Else

I think this is fixed by #1819

the-mikedavis avatar Oct 20 '22 15:10 the-mikedavis

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 avatar Jan 10 '23 22:01 pascalkuthe

@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?

David-Else avatar Jan 28 '23 09:01 David-Else

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

pascalkuthe avatar Jan 28 '23 10:01 pascalkuthe

#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.

pascalkuthe avatar Jan 30 '23 02:01 pascalkuthe