aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorhistoria <gravel.justness270@slmail.me>2024-08-16 04:38:53 -0400
committerhistoria <gravel.justness270@slmail.me>2024-08-16 04:38:53 -0400
commitc4f9f35dc052e5785aa85b3ee30d718ef211d03c (patch)
tree82179997ca34e56006b10a99da9c2d8bcdf99e04 /lua
parentc51c272a7eaf4989ef6f374ae9eb4c35f06fdb56 (diff)
downloaddenote-fzf-lua-c4f9f35dc052e5785aa85b3ee30d718ef211d03c.tar.gz
fix: error when no search results
Diffstat (limited to 'lua')
-rw-r--r--lua/denote-fzf-lua.lua8
1 files changed, 4 insertions, 4 deletions
diff --git a/lua/denote-fzf-lua.lua b/lua/denote-fzf-lua.lua
index d685ef9..094f280 100644
--- a/lua/denote-fzf-lua.lua
+++ b/lua/denote-fzf-lua.lua
@@ -76,7 +76,7 @@ end
---@param delim string delimiter character
---Puts a field from the search results back into Denote format (e.g. two words to --two-words)
function M.repopulate_field(f, delim)
- if f == "." then
+ if f == "." then
return ""
else
return delim .. delim .. f:gsub("%s",delim)
@@ -85,6 +85,7 @@ end
---@param filename string chopped up string with fields separated by multiple spaces
function M.recombine_filename(filename)
+ if filename == nil then return "" end
local t = {}
filename = filename:gsub("%s%s+", "|")
t.path, t.year, t.month, t.day, t.hour, t.min, t.sec, t.sig, t.title, t.keywords, t.ext =
@@ -98,7 +99,7 @@ end
---@param options table of user options
---Opens a window to search filenames
function M.search_files(options)
- script_path = M.set_script_path(options.force_slow_mode)
+ local script_path = M.set_script_path(options.force_slow_mode)
if not script_path then return end
local opts = {}
opts.previewer = M.recombine_previewer
@@ -106,9 +107,8 @@ function M.search_files(options)
opts.fzf_opts["--with-nth"] = M.format_fzf_with_nth(options)
opts.fzf_opts['--header-lines'] = 1
opts.fzf_opts['--delimiter'] = "\\s{2,}"
- -- print(vim.inspect(opts))
opts.actions = {
- ['default'] = function(selected, opts)
+ ['default'] = function(selected)
local filename = M.recombine_filename(selected[1])
vim.api.nvim_command('edit ' .. filename)
end }