diff --git a/lua/yazi/keybinding_helpers.lua b/lua/yazi/keybinding_helpers.lua index 48bc78f6..a2d6f595 100644 --- a/lua/yazi/keybinding_helpers.lua +++ b/lua/yazi/keybinding_helpers.lua @@ -215,7 +215,8 @@ end ---@param context YaziActiveContext function YaziOpenerActions.change_working_directory(context) local last_directory = context.ya_process.cwd - if last_directory then + or context.input_path:parent().filename + if last_directory and last_directory ~= vim.fn.getcwd() then vim.notify('cwd changed to "' .. last_directory .. '"') vim.cmd({ cmd = "cd", args = { last_directory } }) end