-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: report parent directory of input_path as last_directory
Background ========== When yazi is started too late, it can happen that we don't know what the last_directory was when yazi has exited. When this happens, yazi has already reported its `cd` event before `ya` starts and yazi.nvim cannot capture it. The issue can be tracked in sxyazi/yazi#1314 Issue ===== Currently yazi.nvim works around this limitation by using the parent directory of the input_path as the last_directory since it's a good guess. However, it looks like this has never worked reliably due to a bug in the implementation. The correct directory was calculated, but it was not assigned to the last_directory field in the state - it was ignored and had no effect. Solution ======== Assign the correct directory to the last_directory field in the state.
- Loading branch information
1 parent
907b537
commit 6295532
Showing
3 changed files
with
112 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
local M = {} | ||
|
||
---@param target_file string | ||
function M.create_test_file(target_file) | ||
local plenary_path = require("plenary.path") | ||
local file = io.open(target_file, "w") -- Open or create the file in write mode | ||
assert(file, "Failed to create file " .. target_file) | ||
if file then | ||
file:write("") | ||
file:close() | ||
end | ||
assert(plenary_path:new(target_file):exists()) | ||
assert(plenary_path:new(target_file):is_file()) | ||
assert(plenary_path:new(target_file):parent():is_dir()) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters