mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(lsp): token_edit.data might be null on deletion (#21462)
This commit is contained in:
@@ -323,7 +323,9 @@ function STHighlighter:process_response(response, client, version)
|
|||||||
local idx = 1
|
local idx = 1
|
||||||
for _, token_edit in ipairs(token_edits) do
|
for _, token_edit in ipairs(token_edits) do
|
||||||
vim.list_extend(tokens, old_tokens, idx, token_edit.start)
|
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
|
idx = token_edit.start + token_edit.deleteCount + 1
|
||||||
end
|
end
|
||||||
vim.list_extend(tokens, old_tokens, idx)
|
vim.list_extend(tokens, old_tokens, idx)
|
||||||
|
@@ -1109,7 +1109,36 @@ int main()
|
|||||||
extmark_added = true,
|
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
|
}) do
|
||||||
it(test.it, function()
|
it(test.it, function()
|
||||||
exec_lua(create_server_definition)
|
exec_lua(create_server_definition)
|
||||||
|
Reference in New Issue
Block a user