Skip to content

Commit

Permalink
fix: not being able to open files with special chars on osx
Browse files Browse the repository at this point in the history
when nvim was editing a file with spaces in its name, it would not be
preselected as the current file when opening yazi. This seems like a
regression.
  • Loading branch information
mikavilpas committed May 14, 2024
1 parent 73ff4d9 commit f5390c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lua/yazi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function M.yazi(config, path)

os.remove(config.chosen_file_path)
local cmd = string.format(
'yazi "%s" --local-events "rename,delete,trash,move" --chooser-file "%s" > "%s"',
'yazi %s --local-events "rename,delete,trash,move" --chooser-file "%s" > "%s"',
path_utils.escape_path_for_cmd(path),
config.chosen_file_path,
config.events_file_path
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
7 changes: 4 additions & 3 deletions tests/yazi/yazi_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ describe('opening a file', function()
end

it('opens yazi with the current file selected', function()
vim.api.nvim_command('edit ' .. vim.fn.fnameescape('/abc/test-file-$1.txt'))
-- the file name should have a space as well as special characters, in order to test that
vim.api.nvim_command('edit ' .. vim.fn.fnameescape('/abc/test file-$1.txt'))
plugin.yazi({
chosen_file_path = '/tmp/yazi_filechosen',
events_file_path = '/tmp/yazi.nvim.events.txt',
})

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 @@ -55,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 f5390c5

Please sign in to comment.