Skip to content

Commit

Permalink
fix: not being able to open file names with complex characters
Browse files Browse the repository at this point in the history
Fixes #60
  • Loading branch information
mikavilpas committed Apr 29, 2024
1 parent 6cfc985 commit bdec3b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/yazi/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ function M.on_yazi_exited(prev_win, window, config)
local chosen_file = chosen_files[1]
config.hooks.yazi_closed_successfully(chosen_file, config)
if chosen_file then
config.open_file_function(chosen_file, config)
local path = vim.fn.fnameescape(chosen_file)
config.open_file_function(path, config)
end
end
end
Expand Down
10 changes: 10 additions & 0 deletions tests/yazi/yazi_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ describe('opening a file', function()

assert.equals(target_file, vim.fn.expand('%'))
end)

it('can open files with complex characters in their name', function()
-- the filename contains a '$' character which can be problematic to nvim
local target_file = 'routes/posts.$postId/route.tsx'
setup_fake_yazi_opens_file(target_file)

plugin.yazi({ set_keymappings_function = function() end })

assert.equals(target_file, vim.fn.expand('%'))
end)
end)

it(
Expand Down

0 comments on commit bdec3b6

Please sign in to comment.