neovim

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

commit 72e64a1afef0df1bd244bfb31dfc8619d91ff709
parent 3d948a4dc4b2cd3c8d3ac497caf3dfe25adfb90d
Author: Raphael <glephunter@gmail.com>
Date:   Fri, 11 Aug 2023 20:20:05 +0800

fix(lsp): extra "." when completing with tsserver #24646

Problem:
With tsserver LSP, omni completion after "." inserts an extra "."

Solution:
Apply adjust_start_col() regardless of `filterText`.
adjust_start_col() is explained here:
https://github.com/neovim/neovim/blob/0ea8dfeb3dc347579753169d9e3588f6306ab703/runtime/lua/vim/lsp.lua#L2334-L2351

The `filterText` field is used in the following situations rather than as
a condition for obtaining column values:
1. Real-time filtering: When the user types characters in the editor, the
   language server can use the filterText field to filter the list of
   suggestions and only return suggestions that match the typed characters. This
   helps to provide more precise recommendations.
2. Fuzzy matching: The filterText field can be used to perform fuzzy matching,
   allowing matching in the middle or beginning of input characters, not limited
   to prefix matching. This can provide a more flexible code completion
   experience.

Inspecting usage of `filtertext` in vim-lsp and coc and lsp-mode:
- vim-lsp uses a `refresh_pattern` to judge filterText as completionitem word
  (although I think this is not the correct usage).
- coc uses it for filtering.

Fix #22803
Diffstat:
Mruntime/lua/vim/lsp.lua | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua @@ -2262,7 +2262,7 @@ end local function adjust_start_col(lnum, line, items, encoding) local min_start_char = nil for _, item in pairs(items) do - if item.filterText == nil and item.textEdit and item.textEdit.range.start.line == lnum - 1 then + if item.textEdit and item.textEdit.range.start.line == lnum - 1 then if min_start_char and min_start_char ~= item.textEdit.range.start.character then return nil end