Skip to content

Commit 7f7f840

Browse files
phanenibhagwan
authored andcommitted
fix: nil-check opts.cmd #2188
1 parent 9864a16 commit 7f7f840

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

lua/fzf-lua/actions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,7 @@ M.toggle_flag = function(_, opts)
10311031
local o = vim.tbl_deep_extend("keep", {
10321032
-- grep|live_grep sets `opts._cmd` to the original
10331033
-- command without the search argument
1034-
cmd = utils.toggle_cmd_flag(opts._cmd or opts.cmd, opts.toggle_flag),
1034+
cmd = utils.toggle_cmd_flag(assert(opts._cmd or opts.cmd), assert(opts.toggle_flag)),
10351035
resume = true
10361036
}, opts.__call_opts)
10371037
opts.__call_fn(o)

lua/fzf-lua/make_entry.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ M.preprocess = function(opts)
245245
end)
246246
end
247247

248-
if utils.__IS_WINDOWS and opts.cmd:match("!") then
248+
if utils.__IS_WINDOWS and opts.cmd and opts.cmd:match("!") then
249249
-- https://ss64.com/nt/syntax-esc.html
250250
-- This changes slightly if you are running with DelayedExpansion of variables:
251251
-- if any part of the command line includes an '!' then CMD will escape a second

lua/fzf-lua/providers/files.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ local make_entry = require "fzf-lua.make_entry"
88

99
local M = {}
1010

11+
---@param opts table
12+
---@return string
1113
local get_files_cmd = function(opts)
1214
if opts.raw_cmd and #opts.raw_cmd > 0 then
1315
return opts.raw_cmd

lua/fzf-lua/utils.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,12 +1442,12 @@ function M.termopen(cmd, opts)
14421442
end
14431443
end
14441444

1445+
---@param cmd string
1446+
---@param flag string
1447+
---@param enabled boolean?
1448+
---@param append boolean?
1449+
---@return string
14451450
function M.toggle_cmd_flag(cmd, flag, enabled, append)
1446-
if not flag then
1447-
M.err("'toggle_flag' not set")
1448-
return
1449-
end
1450-
14511451
-- flag must be preceded by whitespace
14521452
if not flag:match("^%s") then flag = " " .. flag end
14531453

0 commit comments

Comments
 (0)