Skip to content

Commit 22c5c0d

Browse files
committed
fix: path source not handling hidden files correctly
Closes #369
1 parent e328bde commit 22c5c0d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lua/blink/cmp/sources/path/init.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ function path:get_completions(context, callback)
3838
if not dirname then return callback({ is_incomplete_forward = false, is_incomplete_backward = false, items = {} }) end
3939

4040
local include_hidden = self.opts.show_hidden_files_by_default
41-
or string.sub(context.line, context.bounds.start_col - 1, context.bounds.start_col - 1) == '.'
41+
or (string.sub(context.line, context.bounds.start_col, context.bounds.start_col) == '.' and context.bounds.length == 0)
42+
or (
43+
string.sub(context.line, context.bounds.start_col - 1, context.bounds.start_col - 1) == '.'
44+
and context.bounds.length > 0
45+
)
4246
lib
4347
.candidates(dirname, include_hidden, self.opts)
4448
:map(

lua/blink/cmp/sources/path/lib.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function lib.candidates(dirname, include_hidden, opts)
5151
return fs.scan_dir_async(dirname)
5252
:map(function(entries) return fs.fs_stat_all(dirname, entries) end)
5353
:map(function(entries)
54-
return vim.tbl_filter(function(entry) return include_hidden or entry.name ~= '.' end, entries)
54+
return vim.tbl_filter(function(entry) return include_hidden or entry.name:sub(1, 1) ~= '.' end, entries)
5555
end)
5656
:map(function(entries)
5757
return vim.tbl_map(function(entry) return lib.entry_to_completion_item(entry, dirname, opts) end, entries)

0 commit comments

Comments
 (0)