Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept error (missing textEdit.range) #178

Closed
3rd opened this issue Oct 23, 2024 · 7 comments
Closed

Accept error (missing textEdit.range) #178

3rd opened this issue Oct 23, 2024 · 7 comments

Comments

@3rd
Copy link

3rd commented Oct 23, 2024

Hi, I've been hitting this weird issue where textEdit.range is nil when selecting a completion.
I never manager to hit it when working with Lua, but when working with TypeScript it's frequent.
Thank you for all the work!

ts_get_from_item.mp4
@Saghen
Copy link
Owner

Saghen commented Oct 23, 2024

This might be the same as #21. There's a solution in that thread

@3rd
Copy link
Author

3rd commented Oct 24, 2024

Ah I tried, I just checked textDocument.completion.completionItem for all the LSPs.

"cssmodules_ls"
{
  commitCharactersSupport = false,
  deprecatedSupport = false,
  documentationFormat = { "markdown", "plaintext" },
  insertReplaceSupport = false,
  preselectSupport = false,
  snippetSupport = false
}
"eslint"
{
  commitCharactersSupport = false,
  deprecatedSupport = false,
  documentationFormat = { "markdown", "plaintext" },
  insertReplaceSupport = false,
  preselectSupport = false,
  snippetSupport = false
}
"tailwindcss"
{
  commitCharactersSupport = false,
  deprecatedSupport = false,
  documentationFormat = { "markdown", "plaintext" },
  insertReplaceSupport = false,
  preselectSupport = false,
  snippetSupport = false
}
"typescript-tools"
{
  commitCharactersSupport = false,
  deprecatedSupport = false,
  documentationFormat = { "markdown", "plaintext" },
  preselectSupport = false,
  snippetSupport = false
}
"ast_grep"
{
  commitCharactersSupport = false,
  deprecatedSupport = false,
  documentationFormat = { "markdown", "plaintext" },
  insertReplaceSupport = false,
  preselectSupport = false,
  snippetSupport = false
}
"lua_ls"
{
  commitCharactersSupport = false,
  deprecatedSupport = false,
  documentationFormat = { "markdown", "plaintext" },
  insertReplaceSupport = false,
  preselectSupport = false,
  snippetSupport = false
}

@Saghen
Copy link
Owner

Saghen commented Oct 24, 2024

My best guess is the LSP is returning a itemDefaults.editRange which I have yet to add support for. Do me a favor and send the output of this snippet at the position where the error occurs:

vim.lsp.buf_request_all(
  0,
  'textDocument/completion',
  vim.lsp.util.make_position_params(),
  function(result) vim.print(result) end
)

The LSP shouldn't be sending this since we don't advertise support but some LSPs seem to ignore that bit of the spec

@3rd
Copy link
Author

3rd commented Oct 24, 2024

Logged it here: https://gist.ro/blink.txt

The weird part is that it only happens when the completion menu shows up after ., but if I type any prefix like .f| everything works fine 👀

I added a check to prevent throwing the error, but it introduced a side-effect of duplicating dots when navigating the menu (so . -> -> ..member) and introducing a third dot on accept (-> ...member)

@Saghen
Copy link
Owner

Saghen commented Oct 24, 2024

Reproduced it with typescript-tools and this looks to be the same as #21. You might want to use ts_ls or vtsls temporarily as I can't see a way to disable this behavior with typescript-tools

@Saghen Saghen closed this as not planned Won't fix, can't repro, duplicate, stale Oct 24, 2024
Saghen added a commit that referenced this issue Oct 24, 2024
@Saghen
Copy link
Owner

Saghen commented Oct 24, 2024

Scratch that, it was surprisingly trivial to workaround this temporarily

@3rd
Copy link
Author

3rd commented Oct 24, 2024

Works great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants