-
Notifications
You must be signed in to change notification settings - Fork 698
feat: tree view for the preset archive previewer #3525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This looks fantastic! There's a problem though - when I seek down the preview (pressing the |
|
Yeah 7-Zip sometimes doesn't report directory status or even any attributes for a file. Do you think detect directories solely from the path? For example, for the path |
a7fb778 to
ebedab3
Compare
|
I have added auto detection for directories. Sadly, this only works if the files are listed in the correct lexical order, which is the order by default on a created zip, but isn't actually the order that 7z lists the files in - 7z just lists the files in an order decided by the compressor of the file. This can lead to bad situations like this one (seems to only happen on zip files, although I'm not 100% sure it can't happen on tarballs)
And with the current architecture, I don't think there is much that can be done - because if we sort the files we have listed (which are limitted to the height of the terminal), scrolling through the archive will be very weird. We would have to get all the files in the archive and then sort them, but then that can add a lot of overhead. I haven't really looked into a way to recreate an example zip file which has problematic order. I however personally believe that the current behavior, where the archive is required to have been created with files in lexical order (which has been the default on 7z for years), is good enough, as it should regard most of the archive files out there. |
c16d790 to
646b008
Compare
archive preview|
Hi, I did some refactoring to simplify the code, could you have a look to see if there are any errors? During testing I found an issue: if an archive has a deep directory structure, scroll down to the end can cause some files to be lost, here's the steps to repruduce it:
Do you have any idea how to fix this? |
|
We created a bunch of rows for directories - these aren't listed inside the I'm not sure how job.skip is defined though, or if we can modify it... |
|
yazi/yazi-plugin/preset/plugins/code.lua Lines 18 to 24 in d156508
But we can't get 7-Zip's output inside the |
|
OK I think I've found a way to fix it in dce7115, there are no blockers now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds tree view functionality to the preset archive previewer, displaying directories in archives with visual hierarchy using tree characters.
Changes:
- Refactored archive listing to build a tree structure from flat file lists
- Added
treelizefunction to compute parent directories and depth for tree visualization - Fixed a logic bug in filesystem partition heuristic detection (inverted from
is_none_ortois_some_and)
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| yazi-plugin/preset/plugins/archive.lua | Main changes: added tree view rendering with depth indicators, refactored parsing to remove bound return value, added treelize and make_file helper functions |
| yazi-fs/src/mounts/partitions.rs | Changed heuristic detection logic from is_none_or to is_some_and |
| yazi-fs/src/mounts/partition.rs | Minor comment update removing redundant text |
| Cargo.toml | Updated ansi-to-tui to 8.0.1 and toml to 0.9.11 |
| Cargo.lock | Lockfile updates for dependency changes |
| cspell.json | Added "treelize" to dictionary |
| CHANGELOG.md | Added entry for tree view feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function M.list_archive(args, skip, limit) | ||
| local child = M.spawn_7z { "l", "-ba", "-slt", "-sccUTF-8", table.unpack(args) } | ||
| if not child then | ||
| return {}, 0, Err("Failed to start either `7zz` or `7z`. Do you have 7-zip installed?") |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return statement includes an extra value 0 that doesn't match the updated function signature. This function now returns only files and err, but this error path returns three values: {}, 0, and an Error. The 0 should be removed to match the new signature.
| { "l", "-ba", "-slt", "-ttar", "-sccUTF-8", "-si" } | ||
| ) | ||
| if not dst then | ||
| return {}, 0, Err("Failed to start either `7zz` or `7z`. Do you have 7-zip installed?") |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return statement includes an extra value 0 that doesn't match the updated function signature. This function now returns only files and err, but this error path returns three values: {}, 0, and an Error. The 0 should be removed to match the new signature.
| #[cfg(any(target_os = "linux", target_os = "macos"))] | ||
| { | ||
| self.by_dev(_cha.dev).is_none_or(|p| p.heuristic()) | ||
| self.by_dev(_cha.dev).is_some_and(|p| p.heuristic()) |
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic has been inverted from is_none_or to is_some_and, which changes the behavior. Previously, this returned true if there was no matching partition OR if the partition requires heuristic polling. Now it returns true only if there IS a matching partition AND it requires heuristic polling. This means directories on unmounted/unknown filesystems will no longer use heuristic polling, which could be a breaking behavioral change. Please verify this is the intended behavior.
| self.by_dev(_cha.dev).is_some_and(|p| p.heuristic()) | |
| self.by_dev(_cha.dev).is_none_or(|p| p.heuristic()) |
| ::continue:: | ||
| until i >= skip + limit | ||
| until #files > skip + limit | ||
|
|
Copilot
AI
Jan 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the last file in the stream doesn't end with a blank line, it won't go through the treelize function (which is only called at line 254 when a blank line is encountered). This means the last file may not have the depth and is_dir fields set, which will cause issues when rendering (line 41 uses f.depth, line 25 uses f.is_dir). Consider calling treelize for the last file if it has a non-empty path before checking at line 276.
| -- Ensure the last file is treelized if it represents a real entry | |
| if files[#files].path ~= empty then | |
| M.treelize(files, parents) | |
| end |
sxyazi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [sxyazi/yazi](https://github.com/sxyazi/yazi) | patch | `v26.1.4` → `v26.1.22` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>sxyazi/yazi (sxyazi/yazi)</summary> ### [`v26.1.22`](https://github.com/sxyazi/yazi/blob/HEAD/CHANGELOG.md#v26122) [Compare Source](sxyazi/yazi@v26.1.4...v26.1.22) ##### Added - Tree view for the preset archive previewer (\[[#​3525](sxyazi/yazi#3525)]) - Support compressed tarballs (`.tar.gz`, `.tar.bz2`, etc.) in the preset archive previewer (\[[#​3518](sxyazi/yazi#3518)]) - Check and refresh the file list when the terminal gains focus (\[[#​3561](sxyazi/yazi#3561)]) - Experimental module-level async support (\[[#​3594](sxyazi/yazi#3594)]) - Disable ANSI escape sequences in `ya pkg` when stdout is not a TTY (\[[#​3566](sxyazi/yazi#3566)]) - New `Path.os()` API creates an OS-native `Path` (\[[#​3541](sxyazi/yazi#3541)]) ##### Fixed - Smart-case in interactive `cd` broken due to a typo (\[[#​3540](sxyazi/yazi#3540)]) - Fix shell formatting for non-spread opener rules (\[[#​3532](sxyazi/yazi#3532)]) - `sort extension` excludes directories since only files have extensions (\[[#​3582](sxyazi/yazi#3582)]) - Account for URL covariance in `Url:join()` (\[[#​3514](sxyazi/yazi#3514)]) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi44OC4yIiwidXBkYXRlZEluVmVyIjoiNDIuODguMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6OnBhdGNoIl19-->






Which issue does this PR resolve?
Follow-up on #3518
Rationale of this PR
Two changes:
archiveplugin to display their own file lists in a beautiful list with icons and colors