lexical-lsp / lexical

Lexical is a next-generation elixir language server
776 stars 77 forks source link

selecting suggestion for `defmodule` doesn't work in helix #735

Closed tcoopman closed 1 month ago

tcoopman commented 1 month ago

Here is a recording of what happens. I'm not sure if this a lexical or helix bug. But I don't have similar issues with other lsps in helix.

https://asciinema.org/a/EoHl9jRppjIeEnTx3eOCK2ore

I've created a discussion for this in the past, but got no reaction - so creating a bug with some more information. (https://github.com/lexical-lsp/lexical/discussions/622)

scohen commented 1 month ago

When starting a new file like this (| represents the cursor position)

d|

Lexical generates the following completion with ranges:

    "detail": "",
    "filterText": "defmodule",
    "insertTextFormat": 2,
    "kind": 7,
    "label": "defmodule (define a module)",
    "sortText": "0401_defmodule (define a module)",
    "textEdit": {
      "newText": "defmodule ${1:New} do\n  $0\nend",
      "range": {
        "end": {
          "character": 1,
          "line": 0
        },
        "start": {
          "character": 0,
          "line": 0
        }
      }
    }
  }

this position consumes the existing 'd'.

I think this is a helix bug, the range is correct and not out of bounds. It's also permissible to make the range from line: 0, character: 0 to line: 0, character: 0, which will insert all of the replacement text at the beginning of the document. I have no idea why it'd be complaining about why that's out of bounds.

This also works well in neovim, vim, vscode, emacs and zed.

scohen commented 1 month ago

Any progress, @tcoopman ?

tcoopman commented 1 month ago

I've created a bug on helix https://github.com/helix-editor/helix/issues/10835

Will close this one.