neovim

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

commit a7c21f4b177a68c246ffcfc627d3302626a5b94a
parent 7beb0eeb4b0ab2ef3ca322c6c98c6e66d8927cfd
Author: Pig Fang <g-plane@hotmail.com>
Date:   Sun, 30 Nov 2025 17:10:42 +0800

test(lsp): polish tests of refreshing diagnostics

Diffstat:
Mtest/functional/plugin/lsp/diagnostic_spec.lua | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 62 insertions(+), 10 deletions(-)

diff --git a/test/functional/plugin/lsp/diagnostic_spec.lua b/test/functional/plugin/lsp/diagnostic_spec.lua @@ -607,19 +607,71 @@ describe('vim.lsp.diagnostic', function() eq('related bad!', related_diagnostics[1].message) eq('spongebob', relatedPreviousResultId) end) + end) + describe('vim.lsp.diagnostic.on_refresh', function() it('refreshes diagnostics on server-to-client request', function() - eq( - 1, - exec_lua(function() - vim.lsp.diagnostic.on_refresh(nil, nil, { - method = 'workspace/diagnostic/refresh', - client_id = client_id, - }) + exec_lua(create_server_definition) + exec_lua(function() + _G.requests = 0 + _G.server = _G._create_server({ + capabilities = { + diagnosticProvider = {}, + }, + handlers = { + ['textDocument/diagnostic'] = function(_, params) + _G.params = params + _G.requests = _G.requests + 1 + vim.lsp.diagnostic.on_diagnostic(nil, { + kind = 'full', + items = { + _G.make_warning('Pull Diagnostic', 4, 4, 4, 4), + }, + }, { + params = { + textDocument = { uri = fake_uri }, + }, + uri = fake_uri, + client_id = client_id, + bufnr = diagnostic_bufnr, + }, {}) + end, + }, + }) + client_id = vim.lsp.start({ name = 'dummy', cmd = _G.server.cmd }) + end) - return _G.requests - end) - ) + local diags = exec_lua(function() + vim.lsp.diagnostic.on_diagnostic(nil, { + kind = 'full', + items = { + _G.make_error('Pull Diagnostic', 4, 4, 4, 4), + }, + }, { + params = { + textDocument = { uri = fake_uri }, + }, + uri = fake_uri, + client_id = client_id, + bufnr = diagnostic_bufnr, + }, {}) + + return vim.diagnostic.get(diagnostic_bufnr) + end) + eq(1, #diags) + eq(1, diags[1].severity) + + local requests, diags = exec_lua(function() + vim.lsp.diagnostic.on_refresh(nil, nil, { + method = 'workspace/diagnostic/refresh', + client_id = client_id, + }) + + return _G.requests, vim.diagnostic.get(diagnostic_bufnr) + end) + eq(1, requests) + eq(1, #diags) + eq(2, diags[1].severity) end) end) end)