diff options
author | Ilia Choly <ilia.choly@gmail.com> | 2024-05-27 11:06:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-27 17:06:03 +0200 |
commit | 292365fa1b8f543ffa2240bb30af34051ad2d7c8 (patch) | |
tree | e46024972c6c26dadfad277507c4b40a38cd1636 /test/functional/plugin/lsp_spec.lua | |
parent | 8893b7b340e012b714cc42f0562f37405be32d51 (diff) | |
download | rneovim-292365fa1b8f543ffa2240bb30af34051ad2d7c8.tar.gz rneovim-292365fa1b8f543ffa2240bb30af34051ad2d7c8.tar.bz2 rneovim-292365fa1b8f543ffa2240bb30af34051ad2d7c8.zip |
fix(lsp): do not detach from buffer if there are uninitialized clients (#29029)
Problem: if on_lines is called before the LSP is initialized, the buffer
is detached.
Solution: check for uninitialized clients before detaching.
Diffstat (limited to 'test/functional/plugin/lsp_spec.lua')
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index c95a96baca..0cf84b50c2 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -530,6 +530,34 @@ describe('LSP', function() ]]) end) + it('should allow on_lines + nvim_buf_delete during LSP initialization #28575', function() + clear() + exec_lua(create_server_definition) + exec_lua([[ + local initialized = false + local server = _create_server({ + handlers = { + initialize = function(method, params, callback) + vim.schedule(function() + callback(nil, { capabilities = {} }) + initialized = true + end) + end + } + }) + local bufnr = vim.api.nvim_create_buf(false, true) + vim.api.nvim_set_current_buf(bufnr) + local client_id = vim.lsp.start({ + name = 'detach-dummy', + cmd = server.cmd, + }) + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, {"hello"}) + vim.api.nvim_buf_delete(bufnr, {}) + local ok = vim.wait(1000, function() return initialized end) + assert(ok, "lsp did not initialize") + ]]) + end) + it('client should return settings via workspace/configuration handler', function() local expected_handlers = { { NIL, {}, { method = 'shutdown', client_id = 1 } }, |