From eaacdc9bdffd98fff6ec788b5526a9c80d16f2cf Mon Sep 17 00:00:00 2001 From: Tomasz N Date: Sun, 8 Feb 2026 22:25:47 +0100 Subject: [PATCH] fix(lsp): ignore empty response on trigger completion #37663 Problem: Empty response affects server start boundary computed before. Solution: Ignore empty responses. This is mostly micro-optimization that avoids extending existing results with empty responses. --- runtime/lua/vim/lsp/completion.lua | 2 +- test/functional/plugin/lsp/completion_spec.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/lsp/completion.lua b/runtime/lua/vim/lsp/completion.lua index 5bdcdc73a5..3ecf425ada 100644 --- a/runtime/lua/vim/lsp/completion.lua +++ b/runtime/lua/vim/lsp/completion.lua @@ -583,7 +583,7 @@ local function trigger(bufnr, clients, ctx) end local result = response.result - if result then + if result and #result.items > 0 then Context.isIncomplete = Context.isIncomplete or result.isIncomplete local encoding = client and client.offset_encoding or 'utf-16' local client_matches, tmp_server_start_boundary diff --git a/test/functional/plugin/lsp/completion_spec.lua b/test/functional/plugin/lsp/completion_spec.lua index 2edad62151..d5ec16eda0 100644 --- a/test/functional/plugin/lsp/completion_spec.lua +++ b/test/functional/plugin/lsp/completion_spec.lua @@ -1455,6 +1455,7 @@ describe('vim.lsp.completion: integration', function() end) create_server('dummy', completion_list) create_server('dummy2', completion_list2) + create_server('dummy3', { isIncomplete = false, items = {} }) feed('Adiv.foo') retry(nil, nil, function() eq(