Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd3468b

Browse files
ByronCopilot
andcommitted
Apply suggestions from Copilot code review
The comment states "standard for CLI tools on all platforms" but this is inaccurate. On Windows, the standard location for configuration files is in the AppData folder (e.g., %APPDATA% or %LOCALAPPDATA%), not ~/.config. While this code will work on Windows if users manually create the .config directory in their home folder, it doesn't follow Windows conventions. Consider using the dirs crate's config_dir() function instead of manually constructing ~/.config, which will use the appropriate platform-specific directory (e.g., %APPDATA% on Windows, ~/.config on Linux, ~/Library/Application Support on macOS). The check !glob_focussed is redundant here because self.focussed == Main already ensures we're not in Glob mode (since glob_focussed = self.focussed == Glob on line 250). While this doesn't cause incorrect behavior and may serve as defensive programming, consider removing it for clarity since the condition self.focussed == Main already guarantees !glob_focussed. Co-authored-by: Copilot <[email protected]>
1 parent c72cb52 commit fd3468b

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

src/config.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ impl Config {
4343
}
4444

4545
fn path() -> Option<PathBuf> {
46-
// Use $XDG_CONFIG_HOME if set, otherwise ~/.config (standard for CLI tools on all platforms).
47-
let config_dir = std::env::var_os("XDG_CONFIG_HOME")
48-
.map(PathBuf::from)
49-
.filter(|p| p.is_absolute())
50-
.or_else(|| dirs::home_dir().map(|h| h.join(".config")))?;
46+
// Use the OS-specific configuration directory (e.g. $XDG_CONFIG_HOME, %APPDATA%, or
47+
// ~/Library/Application Support) as provided by the `dirs` crate.
48+
let config_dir = dirs::config_dir()?;
5149
Some(config_dir.join("dua-cli").join("config.toml"))
5250
}
5351
}

src/interactive/app/eventloop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl AppState {
251251
let mut tree_view = self.tree_view(traversal);
252252

253253
let esc_navigates_back_in_main =
254-
self.esc_navigates_back && key.code == Esc && self.focussed == Main && !glob_focussed;
254+
self.esc_navigates_back && key.code == Esc && self.focussed == Main;
255255

256256
if esc_navigates_back_in_main {
257257
self.pending_exit = false;

0 commit comments

Comments
 (0)