From f5390c528747813548806c65e1134e840d18e739 Mon Sep 17 00:00:00 2001 From: Mika Vilpas Date: Tue, 14 May 2024 18:06:35 +0300 Subject: [PATCH] fix: not being able to open files with special chars on osx 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. --- lua/yazi.lua | 2 +- tests/yazi/open_dir_spec.lua | 2 +- tests/yazi/yazi_spec.lua | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/yazi.lua b/lua/yazi.lua index 95f9c956..52437e6d 100644 --- a/lua/yazi.lua +++ b/lua/yazi.lua @@ -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 diff --git a/tests/yazi/open_dir_spec.lua b/tests/yazi/open_dir_spec.lua index 862c2343..df3bc91f 100644 --- a/tests/yazi/open_dir_spec.lua +++ b/tests/yazi/open_dir_spec.lua @@ -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) diff --git a/tests/yazi/yazi_spec.lua b/tests/yazi/yazi_spec.lua index 83226403..63e7b186 100644 --- a/tests/yazi/yazi_spec.lua +++ b/tests/yazi/yazi_spec.lua @@ -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) @@ -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)