Skip to content

Commit

Permalink
fix(windows): when shellslash is set (closes #1055)
Browse files Browse the repository at this point in the history
Only god and probably Bram (RIP) knows why this option exists
and why anyone would ever use it.
  • Loading branch information
ibhagwan committed Feb 26, 2024
1 parent 3b3cc17 commit fcf9806
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/fzf-lua/fzf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ function M.raw_fzf(contents, fzf_cli_args, opts)
else
table.insert(shell_cmd, table.concat(cmd, " "))
end
-- This obscure option makes jobstart fail with: "The syntax of the command is incorrect"
-- temporarily set to `false`, for more info see `:help shellslash` (#1055)
local nvim_opt_shellslash = utils.__WIN_HAS_SHELLSLASH and vim.o.shellslash
if nvim_opt_shellslash then vim.o.shellslash = false end
jobstart(shell_cmd, {
cwd = cwd,
pty = true,
Expand All @@ -278,6 +282,8 @@ function M.raw_fzf(contents, fzf_cli_args, opts)
end
-- in windows, pipes that are not used are automatically cleaned up
if not utils.__IS_WINDOWS then vim.fn.delete(fifotmpname) end
-- Windows only, restore `shellslash` if was true before `jobstart`
if nvim_opt_shellslash then vim.o.shellslash = nvim_opt_shellslash end
vim.fn.delete(outputtmpname)
if #output == 0 then output = nil end
coroutine.resume(co, output, rc)
Expand Down
2 changes: 2 additions & 0 deletions lua/fzf-lua/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ M.__HAS_NVIM_08 = vim.fn.has("nvim-0.8") == 1
M.__HAS_NVIM_09 = vim.fn.has("nvim-0.9") == 1
M.__HAS_NVIM_010 = vim.fn.has("nvim-0.10") == 1
M.__IS_WINDOWS = vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1
-- `:help shellslash` (for more info see #1055)
M.__WIN_HAS_SHELLSLASH = M.__IS_WINDOWS and vim.fn.exists("+shellslash")


-- limit devicons support to nvim >=0.8, although official support is >=0.7
Expand Down

0 comments on commit fcf9806

Please sign in to comment.