Skip to content

Commit ccc381b

Browse files
committed
fix(cmdline): support wildcard completion in file
1 parent 72a5908 commit ccc381b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lua/blink/cmp/sources/cmdline/init.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ function cmdline:get_completions(context, callback)
4141
local is_path_completion = vim.tbl_contains(constants.completion_types.path, completion_type)
4242
local is_buffer_completion = vim.tbl_contains(constants.completion_types.buffer, completion_type)
4343
local is_filename_modifier_completion = cmdline_utils.contains_filename_modifiers(context.line)
44+
local is_wildcard_completion = cmdline_utils.contains_wildcard(context.line)
4445

45-
local should_split_path = (is_path_completion or is_buffer_completion) and not is_filename_modifier_completion
46+
local should_split_path = (is_path_completion or is_buffer_completion) and not is_filename_modifier_completion and not is_wildcard_completion
4647
local context_line, arguments = cmdline_utils.smart_split(context.line, should_split_path)
4748
local before_cursor = context_line:sub(1, context.cursor[2])
4849
local _, args_before_cursor = cmdline_utils.smart_split(before_cursor, should_split_path)

lua/blink/cmp/sources/cmdline/utils.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ function utils.contains_filename_modifiers(line)
3636
return vim.regex(pat):match_str(line) ~= nil
3737
end
3838

39+
-- Detects whether the provided line contains wildcard, see :h wildcard
40+
---@param line string
41+
---@return boolean
42+
function utils.contains_wildcard(line) return line:find('[%*%?%[%]]') ~= nil end
43+
3944
--- Split the command line into arguments, handling path escaping and trailing spaces.
4045
--- For path completions, split by paths and normalize each one if needed.
4146
--- For other completions, splits by spaces and preserves trailing empty arguments.

0 commit comments

Comments
 (0)