Skip to content

[patch] Fix crash navigating to the parent directory in the filesystem browser - #285

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/filesystem-browser-parent-navigation
Aug 4, 2026
Merged

[patch] Fix crash navigating to the parent directory in the filesystem browser#285
matt-edmondson merged 1 commit into
mainfrom
fix/filesystem-browser-parent-navigation

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #281.

Problem

Double-clicking .. in the filesystem browser crashed on Linux:

System.ArgumentException: Cannot convert "home" to AbsoluteDirectoryPath
   at ktsu.Semantics.Strings.SemanticString`1.PerformValidation[TDest](TDest value)
   at ktsu.ImGui.Popups.ImGuiPopups.FilesystemBrowser.DrawFileTable()

The handler took the parent by trimming directory separators off the path string:

Path.GetDirectoryName(CurrentDirectory.WeakString.Trim(Path.DirectorySeparatorChar))

Trim strips separators from both ends. On Unix the leading / is the root, so /home/lsma became home/lsma, whose parent home is relative and fails AbsoluteDirectoryPath validation. Windows drive paths start with C:\ 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 as Cannot convert "server\share\folder" to AbsoluteDirectoryPath.

A second, quieter bug came from the same line: going up from /home produced 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:

CurrentDirectory = CurrentDirectory.Parent;
RefreshContents();

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 four ktsu.Semantics.* packages together — one repo, one version).

The root-cause fix living in Semantics is why there is no ParentOf helper here and no regression test in this repo: the behaviour under test is AbsoluteDirectoryPath.Parent, and it is covered by 7 new tests in Semantics.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, GetAncestors behaviour), written so the Unix cases execute on Linux CI rather than skipping.

Verification

  • dotnet build ImGui.sln against 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.
  • Ran the .. walk on real Linux (WSL) against ktsu.Semantics.Paths 2.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.
  • Semantics side: full suite 1079 passed, 0 failed.

🤖 Generated with Claude Code

…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
@sonarqubecloud

sonarqubecloud Bot commented Aug 4, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@matt-edmondson
matt-edmondson merged commit 010c519 into main Aug 4, 2026
6 of 7 checks passed
@matt-edmondson
matt-edmondson deleted the fix/filesystem-browser-parent-navigation branch August 4, 2026 07:55
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.

[Bug] (Less severe) Crash when using ".." option in file dialogs in Linux

1 participant