aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/_completion.lua
diff options
context:
space:
mode:
authorLajos Koszti <ajnasz@ajnasz.hu>2023-10-26 22:40:36 +0200
committerGitHub <noreply@github.com>2023-10-26 22:40:36 +0200
commitba6761eafe615a7f904c585dba3b7d6e98f665e1 (patch)
treefe28b726b893168c12dc06770b22f52b1db0ae32 /runtime/lua/vim/lsp/_completion.lua
parent15983cf2c64c527fc13681925d0d00c070c30640 (diff)
downloadrneovim-ba6761eafe615a7f904c585dba3b7d6e98f665e1.tar.gz
rneovim-ba6761eafe615a7f904c585dba3b7d6e98f665e1.tar.bz2
rneovim-ba6761eafe615a7f904c585dba3b7d6e98f665e1.zip
fix(lsp): fix omnicomplete in middle of the line (#25787)
Fixes a regression from 5e5f5174e3faa862a9bc353aa7da41487911140b Until that commit we had a logic like this: `local prefix = startbyte and line:sub(startbyte + 1) or line_to_cursor:sub(word_boundary)` The commit changed the logic and no longer cut off the line at the cursor, resulting in a prefix that included trailing characters
Diffstat (limited to 'runtime/lua/vim/lsp/_completion.lua')
-rw-r--r--runtime/lua/vim/lsp/_completion.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/_completion.lua b/runtime/lua/vim/lsp/_completion.lua
index f0e3af7f03..7a607d6c13 100644
--- a/runtime/lua/vim/lsp/_completion.lua
+++ b/runtime/lua/vim/lsp/_completion.lua
@@ -137,6 +137,7 @@ end
function M._convert_results(
line,
lnum,
+ cursor_col,
client_start_boundary,
server_start_boundary,
result,
@@ -164,7 +165,7 @@ function M._convert_results(
elseif curstartbyte ~= nil and curstartbyte ~= server_start_boundary then
server_start_boundary = client_start_boundary
end
- local prefix = line:sub((server_start_boundary or client_start_boundary) + 1)
+ local prefix = line:sub((server_start_boundary or client_start_boundary) + 1, cursor_col)
local matches = M._lsp_to_complete_items(result, prefix)
return matches, server_start_boundary
end
@@ -212,6 +213,7 @@ function M.omnifunc(findstart, base)
matches, server_start_boundary = M._convert_results(
line,
lnum,
+ cursor_col,
client_start_boundary,
server_start_boundary,
result,