Language-tools: [LS] Code actions don't return version with textDocument

Created on 2 Mar 2021  ·  5Comments  ·  Source: sveltejs/language-tools

This prevents code-actions from working on editors which expect returned version number to be >= of what was sent to the LS.

tsserver sends same version back and code-actions work just fine.

https://github.com/neovim/neovim/blob/c1fbc2ddf15b2f44b615f90b2511349ab974cb83/runtime/lua/vim/lsp/util.lua#L265-L272
Here's code from neovim-lsp that checks version number.

Will edit more information when I find the differences between svelteserver and tsserver regarding sending version number.

Edit: For now these don't work:

Code Actions:                                                                     
1. (svelte) Disable missing-declaration for this line
2. Import 'teenStyle' from module "./helpers"
Fixed bug

All 5 comments

For Svelte files this should be doable, for TS / JS files however we should leave it as currently because we simply do not know what to set it to since we don't get the current document versions of those.

For Svelte files this should be doable, for TS / JS files however we should leave it as currently because we simply do not know what to set it to since we don't get the current document versions of those.

Do you mean the situation when we need to apply changes to external js/ts files due to code-action in svelte component?

Can't think of an example right now. :thinking:

It is interesting, I haven't tested what would happen if I use rename in .ts file. Would that change be reflected in svelte components... :thinking:
Brb. :smile:

Wow... it won't. So it looks like svelte language server should be configured for .ts|.js files in svelte projects too ?

It does not and making this possible is tracked in #580

Renames in Svelte files that affects JS files are an example of where the language server returns edits for JS/TS files.

For Svelte files this should be doable, for TS / JS files however we should leave it as currently because we simply do not know what to set it to since we don't get the current document versions of those.

In the spec the textDocument of the TextDocumentEdit is a OptionalVersionedTextDocumentIdentifier, so the version can be null, and it should be null instead of 0 if the server cannot provide the correct version number.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PatrickG picture PatrickG  ·  3Comments

koddr picture koddr  ·  6Comments

matthewmueller picture matthewmueller  ·  3Comments

JoeDailey picture JoeDailey  ·  6Comments

NickKaramoff picture NickKaramoff  ·  4Comments