Skip to content

Commit 2b60dc7

Browse files
committed
fix wrong label
1 parent 3bc0a0a commit 2b60dc7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lua/phoenix/init.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,18 +535,20 @@ function Snippet:get_completions(prefix)
535535
local snippet_prefix_match = function(p)
536536
for _, item in ipairs(p) do
537537
if vim.startswith(item:lower(), prefix:lower()) then
538-
return true
538+
return item
539539
end
540540
end
541-
return false
541+
return nil
542542
end
543543

544544
local snippets = self.cache[ft]
545545
for trigger, snippet_data in pairs(snippets) do
546546
local snippet_prefix = type(snippet_data.prefix) == 'string' and { snippet_data.prefix }
547547
or snippet_data.prefix
548+
local matched_label = snippet_prefix_match(snippet_prefix)
549+
548550
if
549-
snippet_prefix_match(snippet_prefix)
551+
matched_label
550552
or (
551553
vim.o.completeopt:find('fuzzy')
552554
and next(vim.fn.matchfuzzy({ snippet_prefix }, prefix:lower())) ~= nil
@@ -560,7 +562,7 @@ function Snippet:get_completions(prefix)
560562
end
561563

562564
table.insert(results, {
563-
label = snippet_prefix,
565+
label = matched_label or snippet_prefix,
564566
kind = 15,
565567
filterText = snippet_prefix,
566568
insertText = insert_text,

0 commit comments

Comments
 (0)