feat: hover cursor over the new file after extracting#3854
feat: hover cursor over the new file after extracting#3854
Conversation
There was a problem hiding this comment.
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
extractpreset plugin to compute the extracted target path and emittasks:update_succeedwithtrack=trueso 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 |
There was a problem hiding this comment.
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.
| if target then | |
| if target and job.id then |
| 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 |
There was a problem hiding this comment.
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).
| 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) |
Follow-up for #3846