Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 625f060

Browse files
BreitbandModemMatthias Bidlingmeyer
and
Matthias Bidlingmeyer
authored
feat(refile): improve ux by matching files more fuzzily (#815)
Co-authored-by: Matthias Bidlingmeyer <m.bidlingmeyer@laserhub.com>
1 parent 1657948 commit 625f060

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lua/orgmode/capture/init.lua

+6-8
Original file line numberDiff line numberDiff line change
@@ -408,19 +408,17 @@ end
408408
---@param arg_lead string
409409
---@return string[]
410410
function Capture:autocomplete_refile(arg_lead)
411-
local valid_filenames = self:_get_autocompletion_files(true)
411+
local valid_files = self:_get_autocompletion_files(true)
412412

413-
if not arg_lead then
414-
return vim.tbl_keys(valid_filenames)
413+
if not arg_lead or #arg_lead == 0 then
414+
return vim.tbl_keys(valid_files)
415415
end
416-
local parts = vim.split(arg_lead, '/', { plain = true })
417416

418-
local selected_file = valid_filenames[parts[1] .. '/']
417+
local filename = vim.split(arg_lead, '/', { plain = true })[1]
418+
local selected_file = valid_files[filename .. '/']
419419

420420
if not selected_file then
421-
return vim.tbl_filter(function(file)
422-
return file:match('^' .. vim.pesc(parts[1]))
423-
end, vim.tbl_keys(valid_filenames))
421+
return vim.fn.matchfuzzy(vim.tbl_keys(valid_files), filename)
424422
end
425423

426424
local headlines = selected_file:get_opened_unfinished_headlines()

0 commit comments

Comments
 (0)