Skip to content

Commit

Permalink
fix: crash when current file contains "()" characters in its path/name
Browse files Browse the repository at this point in the history
Fixes #75
  • Loading branch information
mikavilpas committed May 18, 2024
1 parent 163d9b0 commit ca914e0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lua/yazi/utils/path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local M = {}
---@param path string
---@return string
M.escape_path_for_cmd = function(path)
local escaped_path = vim.fn.fnameescape(path)
local escaped_path = vim.fn.shellescape(path)
if M.is_windows then
-- Replace forward slash spaces with just spaces.
escaped_path = escaped_path:gsub('\\ ', ' ')
Expand Down
2 changes: 1 addition & 1 deletion tests/yazi/open_dir_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('when the user set open_for_directories = true', function()
vim.api.nvim_command('edit /')

assert.stub(api_mock.termopen).was_called_with(
'yazi / --local-events "rename,delete,trash,move" --chooser-file "/tmp/yazi_filechosen" > "/tmp/yazi.nvim.events.txt"',
'yazi \'/\' --local-events "rename,delete,trash,move" --chooser-file "/tmp/yazi_filechosen" > "/tmp/yazi.nvim.events.txt"',
match.is_table()
)
end)
Expand Down
4 changes: 2 additions & 2 deletions tests/yazi/yazi_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('opening a file', function()
})

assert.stub(api_mock.termopen).was_called_with(
'yazi /abc/test\\ file-\\$1.txt --local-events "rename,delete,trash,move" --chooser-file "/tmp/yazi_filechosen" > "/tmp/yazi.nvim.events.txt"',
'yazi \'/abc/test file-$1.txt\' --local-events "rename,delete,trash,move" --chooser-file "/tmp/yazi_filechosen" > "/tmp/yazi.nvim.events.txt"',
match.is_table()
)
end)
Expand All @@ -56,7 +56,7 @@ describe('opening a file', function()
})

assert.stub(api_mock.termopen).was_called_with(
'yazi /tmp/ --local-events "rename,delete,trash,move" --chooser-file "/tmp/yazi_filechosen" > "/tmp/yazi.nvim.events.txt"',
'yazi \'/tmp/\' --local-events "rename,delete,trash,move" --chooser-file "/tmp/yazi_filechosen" > "/tmp/yazi.nvim.events.txt"',
match.is_table()
)
end)
Expand Down

0 comments on commit ca914e0

Please sign in to comment.