Skip to content

Commit 56e4dd9

Browse files
Merge pull request #52 from ktaka-ccmp/feat/show-hidden-dirs-clean
feat(file-picker): toggle hidden directories with h key
2 parents b4d522c + 97aab2c commit 56e4dd9

4 files changed

Lines changed: 16 additions & 3 deletions

File tree

src/keybindings/action.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ pub enum Action {
129129
OpenFilePicker,
130130
/// Navigate to parent directory in file picker
131131
ParentDirectory,
132+
/// Toggle visibility of hidden (dot) directories in file picker
133+
ToggleHiddenDirs,
132134

133135
// === Dialog Actions ===
134136
/// Confirm action in dialog
@@ -279,6 +281,7 @@ impl Action {
279281
Action::UndoEdit => "Undo last edit",
280282
Action::OpenFilePicker => "Open file picker",
281283
Action::ParentDirectory => "Go to parent directory",
284+
Action::ToggleHiddenDirs => "Toggle hidden directories",
282285

283286
// Dialog
284287
Action::ConfirmAction => "Confirm",
@@ -396,7 +399,8 @@ impl Action {
396399
| Action::OpenInEditor
397400
| Action::UndoEdit
398401
| Action::OpenFilePicker
399-
| Action::ParentDirectory => "Files",
402+
| Action::ParentDirectory
403+
| Action::ToggleHiddenDirs => "Files",
400404

401405
Action::ConfirmAction
402406
| Action::CancelAction

src/keybindings/defaults.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,9 @@ fn add_file_picker_mode(kb: &mut Keybindings) {
464464
// Search
465465
bind(kb, FilePicker, "/", LinkSearch);
466466

467+
// Toggle hidden directories
468+
bind(kb, FilePicker, "h", ToggleHiddenDirs);
469+
467470
// Exit
468471
bind(kb, FilePicker, "Escape", ExitMode);
469472
bind(kb, FilePicker, "q", Quit);

src/tui/app.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ pub struct App {
350350
pub file_search_active: bool, // Whether search input is active
351351
pub startup_needs_file_picker: bool, // True if started without file arg
352352
pub file_picker_dir: Option<PathBuf>, // Custom directory for file picker
353+
pub show_hidden_dirs: bool, // Whether to show hidden (dot) directories
353354

354355
pub file_history: Vec<FileState>, // Back navigation stack
355356
pub file_future: Vec<FileState>, // Forward navigation stack (for undo back)
@@ -572,6 +573,7 @@ impl App {
572573
file_search_active: false,
573574
startup_needs_file_picker: false,
574575
file_picker_dir: None,
576+
show_hidden_dirs: false,
575577

576578
file_history: Vec::new(),
577579
file_future: Vec::new(),
@@ -1392,6 +1394,10 @@ impl App {
13921394
ParentDirectory => {
13931395
self.file_picker_parent_dir();
13941396
}
1397+
ToggleHiddenDirs => {
1398+
self.show_hidden_dirs = !self.show_hidden_dirs;
1399+
self.scan_markdown_files();
1400+
}
13951401

13961402
// === Dialog Actions ===
13971403
ConfirmAction => {
@@ -3737,7 +3743,7 @@ impl App {
37373743
&& path
37383744
.file_name()
37393745
.and_then(|n| n.to_str())
3740-
.map(|name| !name.starts_with('.'))
3746+
.map(|name| self.show_hidden_dirs || !name.starts_with('.'))
37413747
.unwrap_or(false)
37423748
{
37433749
dirs.push(path);

src/tui/ui/popups.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1002,7 +1002,7 @@ pub fn render_file_picker(frame: &mut Frame, app: &App, area: Rect) {
10021002
let footer_text = if app.file_search_active {
10031003
"Type to filter • Enter: select • Esc: stop search • Backspace: delete"
10041004
} else {
1005-
"j/k: Navigate • /: Filter • Enter: Open • Backspace: Parent dir • Esc: Cancel"
1005+
"j/k: Navigate • /: Filter • Enter: Open • Backspace: Parent dir • h: Hidden dirs • Esc: Cancel"
10061006
};
10071007
lines.push(Line::from(vec![Span::styled(
10081008
footer_text,

0 commit comments

Comments
 (0)