Skip to content

Commit

Permalink
fix: path source not handling hidden files correctly
Browse files Browse the repository at this point in the history
Closes #369
  • Loading branch information
Saghen committed Nov 24, 2024
1 parent e328bde commit 22c5c0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lua/blink/cmp/sources/path/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ function path:get_completions(context, callback)
if not dirname then return callback({ is_incomplete_forward = false, is_incomplete_backward = false, items = {} }) end

local include_hidden = self.opts.show_hidden_files_by_default
or string.sub(context.line, context.bounds.start_col - 1, context.bounds.start_col - 1) == '.'
or (string.sub(context.line, context.bounds.start_col, context.bounds.start_col) == '.' and context.bounds.length == 0)
or (
string.sub(context.line, context.bounds.start_col - 1, context.bounds.start_col - 1) == '.'
and context.bounds.length > 0
)
lib
.candidates(dirname, include_hidden, self.opts)
:map(
Expand Down
2 changes: 1 addition & 1 deletion lua/blink/cmp/sources/path/lib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function lib.candidates(dirname, include_hidden, opts)
return fs.scan_dir_async(dirname)
:map(function(entries) return fs.fs_stat_all(dirname, entries) end)
:map(function(entries)
return vim.tbl_filter(function(entry) return include_hidden or entry.name ~= '.' end, entries)
return vim.tbl_filter(function(entry) return include_hidden or entry.name:sub(1, 1) ~= '.' end, entries)
end)
:map(function(entries)
return vim.tbl_map(function(entry) return lib.entry_to_completion_item(entry, dirname, opts) end, entries)
Expand Down

0 comments on commit 22c5c0d

Please sign in to comment.