fix(tui): resolve cross-platform root detection and fallback paths in pickers#3795
Open
Piyush0049 wants to merge 1 commit into
Open
fix(tui): resolve cross-platform root detection and fallback paths in pickers#3795Piyush0049 wants to merge 1 commit into
Piyush0049 wants to merge 1 commit into
Conversation
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.
Summary
This PR addresses two cross-platform path handling issues in the TUI file and directory picker components to ensure reliable behavior on Windows and POSIX systems.
1. Cross-Platform Root Directory Boundary Detection
d.currentDir != "/"to decide whether to append the..(parent directory) option.C:\). SinceC:\does not equal/, the TUI treatedC:\as a non-root folder and appended a..entry pointing back toC:\, causing an infinite navigation loop.filepath.Dir(d.currentDir) != d.currentDir. This leverages the standard library to verify if a directory is its own parent, which works reliably on Windows, Linux, and macOS.2. Cross-Platform Directory Fallback (
/to.)os.Getwd()returned an error or empty string, the TUI fell back toworkingDir = "/"./as a fallback causes invalid path resolutions on Windows systems when execution context is lost./to.. This aligns with the existing fallback pattern used infile_picker.goand ensures safe resolution relative to the process execution directory across all platforms.Verification
golangci-lint run(0 issues).go test ./pkg/tui/dialog.