[patch] Fix crash navigating to the parent directory in the filesystem browser - #285
Merged
Merged
Conversation
…m browser
Double-clicking ".." trimmed directory separators off both ends of the current
path. Trimming also removes the leading separator, which is the root itself on
Unix (and the UNC prefix on Windows), so the "parent" came back relative and
failed AbsoluteDirectoryPath validation:
System.ArgumentException: Cannot convert "home" to AbsoluteDirectoryPath
at ktsu.ImGui.Popups.ImGuiPopups.FilesystemBrowser.DrawFileTable()
Take the parent from the path type instead. ktsu.Semantics.Paths 2.9.0 makes a
root its own parent, so navigation stays put once there is nowhere left to go and
needs no guard. Earlier versions returned an empty path there, which is why this
also bumps the ktsu.Semantics.* packages from 2.8.1 to 2.9.0.
Fixes #281
Claude-Session: https://claude.ai/code/session_01UwSLytSdW2pHmSmsSBAj8r
|
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.


Fixes #281.
Problem
Double-clicking
..in the filesystem browser crashed on Linux:The handler took the parent by trimming directory separators off the path string:
Trimstrips separators from both ends. On Unix the leading/is the root, so/home/lsmabecamehome/lsma, whose parenthomeis relative and failsAbsoluteDirectoryPathvalidation. Windows drive paths start withC:\rather than a separator, which is why only Linux saw it — but UNC paths (\server\share\…) hit the identical bug on Windows, and that reproduced locally asCannot convert "server\share\folder" to AbsoluteDirectoryPath.A second, quieter bug came from the same line: going up from
/homeproduced an empty path, so the browser silently showed no contents instead of landing on/.Change
Take the parent from the path type instead of doing string math:
No guard is needed because ktsu-dev/Semantics#144 made a root its own parent, so
..simply stays put once there is nowhere left to go. That shipped as ktsu.Semantics 2.9.0, which this PR bumps to (all fourktsu.Semantics.*packages together — one repo, one version).The root-cause fix living in Semantics is why there is no
ParentOfhelper here and no regression test in this repo: the behaviour under test isAbsoluteDirectoryPath.Parent, and it is covered by 7 new tests inSemantics.Test/Paths/AbsoluteDirectoryPathParentTests.cs(parent chains, root-is-its-own-parent, UNC share roots, never returning an empty or relative path while walking up, termination at the fixed point,GetAncestorsbehaviour), written so the Unix cases execute on Linux CI rather than skipping.Verification
dotnet build ImGui.slnagainst 2.9.0: clean, 0 warnings (warnings-as-errors, so the Semantics behaviour change introduced no new diagnostics).dotnet test ImGui.sln: 604 total, 0 failed, 8 OS-skipped...walk on real Linux (WSL) againstktsu.Semantics.Paths2.9.0 from nuget.org, no patched binaries:/home/matt/parenttest → /home/matt → /home → /, then stays at/. The exact exception from the issue no longer occurs.🤖 Generated with Claude Code