From 22c5c0d2c96d5ab86cd23f8df76f005505138a5d Mon Sep 17 00:00:00 2001 From: Liam Dyer Date: Sun, 24 Nov 2024 15:06:40 -0500 Subject: [PATCH] fix: path source not handling hidden files correctly Closes #369 --- lua/blink/cmp/sources/path/init.lua | 6 +++++- lua/blink/cmp/sources/path/lib.lua | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/blink/cmp/sources/path/init.lua b/lua/blink/cmp/sources/path/init.lua index e5ac4af6..7af87e43 100644 --- a/lua/blink/cmp/sources/path/init.lua +++ b/lua/blink/cmp/sources/path/init.lua @@ -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( diff --git a/lua/blink/cmp/sources/path/lib.lua b/lua/blink/cmp/sources/path/lib.lua index 91c7194f..a54c2578 100644 --- a/lua/blink/cmp/sources/path/lib.lua +++ b/lua/blink/cmp/sources/path/lib.lua @@ -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)