Skip to content

Commit

Permalink
omni completion results in an error message after a opening parenthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
yegappan committed Feb 26, 2024
1 parent 0f774f9 commit 0b9bba0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
6 changes: 4 additions & 2 deletions autoload/lsp/completion.vim
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,9 @@ def g:LspOmniFunc(findstart: number, base: string): any

var [triggerKind, triggerChar] = GetTriggerAttributes(lspserver)
if triggerKind < 0
return -1
# previous character is not a keyword character or a trigger character,
# so cancel omni completion.
return -2
endif

# first send all the changes in the current buffer to the LSP server
Expand Down Expand Up @@ -509,7 +511,7 @@ def g:LspOmniFunc(findstart: number, base: string): any
return v:none
endif

var res: list<dict<any>> = lspserver->get('completeItems', [])
var res: list<dict<any>> = lspserver.completeItems
var prefix = lspserver.omniCompleteKeyword

# Don't attempt to filter on the items, when "isIncomplete" is set
Expand Down
26 changes: 24 additions & 2 deletions test/clangd_tests.vim
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ def g:Test_OmniComplete_FirstColumn()
:%bw!
enddef

# Test for doing omni completion from the first column
# Test for doing omni completion with a multibyte character
def g:Test_OmniComplete_Multibyte()
:silent! edit XOmniCompleteMultibyte.c
sleep 200m
Expand All @@ -1493,7 +1493,7 @@ def g:Test_OmniComplete_Multibyte()
:%bw!
enddef

# Test for doing omni completion from the first column
# Test for doing omni completion for a struct field
def g:Test_OmniComplete_Struct()
:silent! edit XOmniCompleteStruct.c
sleep 200m
Expand Down Expand Up @@ -1524,6 +1524,28 @@ def g:Test_OmniComplete_Struct()
:%bw!
enddef

# Test for doing omni completion after an opening parenthesis.
# This used to result in an error message.
def g:Test_OmniComplete_AfterParen()
:silent! edit XOmniCompleteAfterParen.c
sleep 200m
var lines: list<string> =<< trim END
#include <stdio.h>
void Fn(void)
{
printf(
}
END
setline(1, lines)
g:WaitForServerFileLoad(2)
redraw!

cursor(4, 1)
feedkeys("A\<C-X>\<C-O>\<C-Y>", 'xt')
assert_equal(' printf(', getline('.'))
:%bw!
enddef

# Test for inlay hints
def g:Test_InlayHints()
:silent! edit XinlayHints.c
Expand Down

0 comments on commit 0b9bba0

Please sign in to comment.