aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Ming <ofseed@foxmail.com>2025-03-13 10:42:57 +0800
committerYi Ming <ofseed@foxmail.com>2025-03-17 14:44:51 +0800
commit648b7f610162c268af18d286b69a97c5fba6836d (patch)
treeece1aed96a804e6f0b1b0932ef639116bd167fab
parentf1422a313fa57c8c7045163aa209a9fd9166fe5a (diff)
downloadrneovim-648b7f610162c268af18d286b69a97c5fba6836d.tar.gz
rneovim-648b7f610162c268af18d286b69a97c5fba6836d.tar.bz2
rneovim-648b7f610162c268af18d286b69a97c5fba6836d.zip
test(lsp): add a test for resetting the active request after receiving error
-rw-r--r--test/functional/plugin/lsp/semantic_tokens_spec.lua33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp/semantic_tokens_spec.lua b/test/functional/plugin/lsp/semantic_tokens_spec.lua
index 9912bf2063..03dbf6baea 100644
--- a/test/functional/plugin/lsp/semantic_tokens_spec.lua
+++ b/test/functional/plugin/lsp/semantic_tokens_spec.lua
@@ -600,6 +600,39 @@ describe('semantic token highlighting', function()
}
end)
+ it('resets active request after receiving error responses from the server', function()
+ local error = { code = -32801, message = 'Content modified' }
+ exec_lua(function()
+ _G.server2 = _G._create_server({
+ capabilities = {
+ semanticTokensProvider = {
+ full = { delta = false },
+ },
+ },
+ handlers = {
+ -- There is same logic for handling nil responses and error responses,
+ -- so keep responses not nil.
+ --
+ -- if an error response was not be handled, this test will hang on here.
+ --- @param callback function
+ ['textDocument/semanticTokens/full'] = function(_, _, callback)
+ callback(error, vim.fn.json_decode(response))
+ end,
+ --- @param callback function
+ ['textDocument/semanticTokens/full/delta'] = function(_, _, callback)
+ callback(error, vim.fn.json_decode(response))
+ end,
+ },
+ })
+ return vim.lsp.start({ name = 'dummy', cmd = _G.server2.cmd })
+ end)
+ screen:expect([[
+ ^ |
+ {1:~ }|*14
+ |
+ ]])
+ end)
+
it('does not send delta requests if not supported by server', function()
insert(text)
exec_lua(function()