aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2023-01-19 19:37:12 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-01-19 20:42:40 +0000
commit409e6f9d7e690a398c4318a8eab7fd56a2eceda3 (patch)
tree002b2a00b0ea2bb18d90f3d07495a886ccaf0324 /test
parent5f3b76d5cec27181770c2fff33ea417eee275172 (diff)
downloadrneovim-fix_semantic_tokens_pull.tar.gz
rneovim-fix_semantic_tokens_pull.tar.bz2
rneovim-fix_semantic_tokens_pull.zip
fix(semantic_tokens.lua): Fix nil tokens/data in semantic_tokens.luafix_semantic_tokens_pull
Some (poorly-implemented) LSPs can return an empty JSON object in LSP responses, which could cause tokens to be nil, which would eventually cause an error and a bad UI experience. This fix makes sure that the tokens variable is always set to a non-nil value.
Diffstat (limited to 'test')
-rw-r--r--test/functional/plugin/lsp/semantic_tokens_spec.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua
index 9c1ba86fe1..50b91edeb3 100644
--- a/test/functional/plugin/lsp/semantic_tokens_spec.lua
+++ b/test/functional/plugin/lsp/semantic_tokens_spec.lua
@@ -852,6 +852,20 @@ b = "as"]],
},
},
},
+ {
+ it = 'nil_data',
+ text = [[some text]],
+ response = [[{}]], -- Data is nil
+ legend = [[{
+ "tokenTypes": [
+ "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator"
+ ],
+ "tokenModifiers": [
+ "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary"
+ ]
+ }]],
+ expected = {},
+ },
}) do
it(test.it, function()
exec_lua(create_server_definition)