Skip to content

Commit

Permalink
feat: use filter text on non-prefixed test in cmdline
Browse files Browse the repository at this point in the history
  • Loading branch information
Saghen committed Dec 29, 2024
1 parent ef59763 commit 8c194b6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lua/blink/cmp/sources/cmdline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,23 @@ function cmdline:get_completions(context, callback)
:map(function(completions)
local items = {}
for _, completion in ipairs(completions) do
-- remove prefix from the label for lua
local label = completion
if arguments[1] == 'lua' and string.find(completion, current_arg_prefix, 1, true) == 1 then
label = label:sub(#current_arg_prefix + 1)
-- remove prefix from the filter text for lua
local filter_text = completion
if string.find(completion, current_arg_prefix, 1, true) == 1 then
filter_text = completion:sub(#current_arg_prefix + 1)
end

-- for lua, set the filter text to the label
local label = completion
if arguments[1] == 'lua' then label = filter_text end

-- add prefix to the newText
local new_text = completion
if string.find(new_text, current_arg_prefix, 1, true) ~= 1 then new_text = current_arg_prefix .. completion end

table.insert(items, {
label = label,
filterText = filter_text,
sortText = label:lower(),
textEdit = {
newText = new_text,
Expand Down

0 comments on commit 8c194b6

Please sign in to comment.