Skip to content

Commit e5f543d

Browse files
committed
fix: check if item contains brackets before defering to semantic token
1 parent b56a2b1 commit e5f543d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lua/blink/cmp/accept/brackets.lua

+8-7
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@ function brackets.add_brackets(filetype, item)
4848
if brackets.has_brackets_in_front(text_edit, brackets_for_filetype[1]) then
4949
return 'skipped', text_edit, #brackets_for_filetype[1]
5050
end
51-
-- check if configuration incidates we should skip
52-
if not brackets.should_run_resolution(filetype, 'kind') then return 'check_semantic_token', text_edit, 0 end
53-
-- not a function, skip
54-
local CompletionItemKind = require('blink.cmp.types').CompletionItemKind
55-
if item.kind ~= CompletionItemKind.Function and item.kind ~= CompletionItemKind.Method then
56-
return 'check_semantic_token', text_edit, 0
57-
end
5851

5952
-- if the item already contains the brackets, conservatively skip adding brackets
6053
-- todo: won't work for snippets when the brackets_for_filetype is { '{', '}' }
@@ -63,6 +56,14 @@ function brackets.add_brackets(filetype, item)
6356
return 'skipped', text_edit, 0
6457
end
6558

59+
-- check if configuration incidates we should skip
60+
if not brackets.should_run_resolution(filetype, 'kind') then return 'check_semantic_token', text_edit, 0 end
61+
-- not a function, skip
62+
local CompletionItemKind = require('blink.cmp.types').CompletionItemKind
63+
if item.kind ~= CompletionItemKind.Function and item.kind ~= CompletionItemKind.Method then
64+
return 'check_semantic_token', text_edit, 0
65+
end
66+
6667
text_edit = vim.deepcopy(text_edit)
6768
-- For snippets, we add the cursor position between the brackets as the last placeholder
6869
if item.insertTextFormat == vim.lsp.protocol.InsertTextFormat.Snippet then

0 commit comments

Comments
 (0)