Skip to content

feat: hover cursor over the new file after extracting#3854

Open
sxyazi wants to merge 2 commits intomainfrom
pr-1205286d
Open

feat: hover cursor over the new file after extracting#3854
sxyazi wants to merge 2 commits intomainfrom
pr-1205286d

Conversation

@sxyazi
Copy link
Copy Markdown
Owner

@sxyazi sxyazi commented Apr 5, 2026

Follow-up for #3846

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds cursor tracking for the built-in extract plugin so that, after a successful extraction, the file manager can automatically hover/focus the newly created output.

Changes:

  • Reset task-tracking behavior when scheduling async plugin entry tasks.
  • Teach extract preset plugin to compute the extracted target path and emit tasks:update_succeed with track=true so the UI can hover the new item.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
yazi-scheduler/src/scheduler.rs Resets task-tracking behavior for plugin entry tasks to enable “track latest task result” behavior.
yazi-plugin/preset/plugins/extract.lua Propagates extracted target from tidy() and emits tasks:update_succeed for cursor hover on success.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

end
end

if target then
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tasks:update_succeed requires positional arg 0 (id) to deserialize into UpdateSucceedForm. This ya.emit call will emit an action without an id when M:entry() is invoked internally (e.g. the tar special-case calls self:entry { args = ... } without id), causing the tasks handler to fail deserializing the event. Consider guarding on job.id being present, and/or refactoring entry/try_with/tidy to return the final extracted target to the original job so only the outermost call emits tasks:update_succeed with a valid id.

Suggested change
if target then
if target and job.id then

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +75
local target = self:tidy(from, to, tmp)
if not output then
fail("7zip failed to output when extracting '%s', error: %s", from, err)
elseif output.status.code ~= 0 then
fail("7zip exited with error code %s when extracting '%s':\n%s", output.status.code, from, output.stderr)
else
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self:tidy(from, to, tmp) is called before validating output / output.status.code. If 7zip fails or produces partial output, tidy can still move extracted files to the destination and remove the temp dir, and then fail(...) aborts the plugin. To avoid leaving partial/misplaced results on errors, run tidy only after confirming output exists and status.code == 0 (and keep the temp dir for troubleshooting when failing).

Suggested change
local target = self:tidy(from, to, tmp)
if not output then
fail("7zip failed to output when extracting '%s', error: %s", from, err)
elseif output.status.code ~= 0 then
fail("7zip exited with error code %s when extracting '%s':\n%s", output.status.code, from, output.stderr)
else
if not output then
fail("7zip failed to output when extracting '%s', error: %s", from, err)
elseif output.status.code ~= 0 then
fail("7zip exited with error code %s when extracting '%s':\n%s", output.status.code, from, output.stderr)
else
local target = self:tidy(from, to, tmp)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants