neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit f4d8e992bfcd6e9d0097b9d7a022060bd32f2069
parent a7332ba9b429f9676723eb88cffb2068f5a95c9b
Author: tiagovla <30515389+tiagovla@users.noreply.github.com>
Date:   Mon, 19 Dec 2022 05:24:27 -0300

fix(lsp): token_edit.data might be null on deletion (#21462)


Diffstat:
Mruntime/lua/vim/lsp/semantic_tokens.lua | 4+++-
Mtest/functional/plugin/lsp/semantic_tokens_spec.lua | 31++++++++++++++++++++++++++++++-
2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/runtime/lua/vim/lsp/semantic_tokens.lua b/runtime/lua/vim/lsp/semantic_tokens.lua @@ -323,7 +323,9 @@ function STHighlighter:process_response(response, client, version) local idx = 1 for _, token_edit in ipairs(token_edits) do vim.list_extend(tokens, old_tokens, idx, token_edit.start) - vim.list_extend(tokens, token_edit.data) + if token_edit.data then + vim.list_extend(tokens, token_edit.data) + end idx = token_edit.start + token_edit.deleteCount + 1 end vim.list_extend(tokens, old_tokens, idx) diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua @@ -1109,7 +1109,36 @@ int main() extmark_added = true, } }, - } + }, + { + it = 'optional token_edit.data on deletion', + legend = [[{ + "tokenTypes": [ + "comment", "keyword", "operator", "string", "number", "regexp", "type", "class", "interface", "enum", "enumMember", "typeParameter", "function", "method", "property", "variable", "parameter", "module", "intrinsic", "selfParameter", "clsParameter", "magicFunction", "builtinConstant", "parenthesis", "curlybrace", "bracket", "colon", "semicolon", "arrow" + ], + "tokenModifiers": [ + "declaration", "static", "abstract", "async", "documentation", "typeHint", "typeHintComment", "readonly", "decorator", "builtin" + ] + }]], + text1 = [[string = "test"]], + text2 = [[]], + response1 = [[{"data": [0, 0, 6, 15, 1], "resultId": "1"}]], + response2 = [[{"edits": [{ "start": 0, "deleteCount": 5 }], "resultId": "2"}]], + expected1 = { + { + line = 0, + modifiers = { + 'declaration', + }, + start_col = 0, + end_col = 6, + type = 'variable', + extmark_added = true, + } + }, + expected2 = { + }, + }, }) do it(test.it, function() exec_lua(create_server_definition)