fix(explorer): handle Windows drive roots correctly in tree - #2938
Open
peter-lyr wants to merge 1 commit into
Open
fix(explorer): handle Windows drive roots correctly in tree#2938peter-lyr wants to merge 1 commit into
peter-lyr wants to merge 1 commit into
Conversation
On Windows, scandir("D:") (no trailing slash) resolves to the drive’s
current directory (e.g. D:/ob1) instead of the root D:/. snacks’ explorer
tree.norm() stripped the trailing slash from "D:/", producing "D:",
so opening or navigating to a drive root showed the current directory’s
contents (stale) instead of the actual root.
Fix two things in tree.lua:
1. norm: keep the trailing slash for Windows drive roots (D:/).
2. Tree:child: skip empty path segment produced by the trailing slash,
and keep the trailing slash for drive-letter root nodes, avoiding
double slashes (D://name) when joining child paths.
Verified headless on Windows:
- open D:/ -> real root listing (many entries), not stale ob1 contents
- normal directories unchanged
- navigating D:/ob1 up to D:/ now shows the drive root correctly
peter-lyr
force-pushed
the
fix/windows-drive-root
branch
from
August 24, 2026 04:16
5c35ba6 to
b12904e
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows,
scandir("D:")(no trailing slash) resolves to the drive's current directory (e.g.D:/ob1) instead of the drive rootD:/.snacks' explorer
tree.norm()stripped the trailing slash from"D:/"producing"D:". So opening or navigating to a drive root showed the current directory's contents (stale/obfuscated) instead of the actual root.Repro: open explorer at
D:/ob1, press<BS>(explorer_up) → it goes toD:/but the list still showsob1's children (Inbox, Life, ...) mislabeled asD:/...instead of the real root (79+ entries on the user's drive).Fix
In
lua/snacks/explorer/tree.lua:norm: keep the trailing slash for Windows drive roots (D:/), soscandir("D:/")resolves to the actual root.Tree:child: skip empty path segments produced by the trailing slash, and keep the trailing slash for drive-letter root nodes (D:/), while avoiding double slashes (D://name) when concatenating child paths.Verified
Headless on Windows (nvim + real snacks):
open D:/now shows the real drive root contents (many entries), not the stale current-dir listD:/ob1/D:/ob1/nvimunchangedD:/ob1up toD:/now lists the drive root correctly