diff options
author | Lajos Koszti <ajnasz@ajnasz.hu> | 2022-02-11 14:04:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-11 14:04:15 +0100 |
commit | f6329ea137730e571671ee31309ec1b7dc6ec85e (patch) | |
tree | e4818bf810fd2d0735b225c32ac6de2f63345d88 /runtime/lua/vim/lsp.lua | |
parent | b981c231e2a74f0232d1eea60ae119d37672d05b (diff) | |
download | rneovim-f6329ea137730e571671ee31309ec1b7dc6ec85e.tar.gz rneovim-f6329ea137730e571671ee31309ec1b7dc6ec85e.tar.bz2 rneovim-f6329ea137730e571671ee31309ec1b7dc6ec85e.zip |
fix(lsp): correct prefix when filterText is present (#17051)
LSP server might return an item which would replace a token to another.
For example in typescript for a `jest.Mock` object `getProductsMock.`
text I get the following response:
```
{
commitCharacters = {
".",
",",
"("
},
data = {
entryNames = {
"Symbol"
},
file = "/foo/bar/baz.service.spec.ts",
line = 268,
offset = 17
},
filterText = ".Symbol",
kind = 6,
label = "Symbol",
sortText = "11",
textEdit = {
newText = "[Symbol]",
range = {
end = {
character = 16,
line = 267
},
start = {
character = 15,
line = 267
}
}
}
},
```
In `lsp.omnifunc` to get a `prefix` we call the `adjust_start_col` which
then returns the `textEdit.range.start.character`.
Th `prefix` then be the `.` character. Then when filter the items with
`remove_unmatch_completion_items`, every item will be filtered out,
since no completion word starts `.`.
To fix we return the `end.character`, which in that particular case will
be the position after the `.`.
Diffstat (limited to 'runtime/lua/vim/lsp.lua')
-rw-r--r-- | runtime/lua/vim/lsp.lua | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua index 37e222a5ce..8d11b4621c 100644 --- a/runtime/lua/vim/lsp.lua +++ b/runtime/lua/vim/lsp.lua @@ -1598,7 +1598,7 @@ end local function adjust_start_col(lnum, line, items, encoding) local min_start_char = nil for _, item in pairs(items) do - if item.textEdit and item.textEdit.range.start.line == lnum - 1 then + if item.filterText == nil and 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 |