Skip to content

Commit 9a7763b

Browse files
committed
fix: directory preview respects showHidden + shell description + test completeness
1 parent e22c2e5 commit 9a7763b

5 files changed

Lines changed: 27 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
3333
- `G` jump now resets preview scroll and diff mode (`handlers.go`)
3434
- Extracted `resetPreview()` to eliminate duplicate navigation reset code (`handlers.go`, `commands.go`)
3535
- `config.example.yaml` rewritten in English (was Chinese)
36+
- Directory preview now respects `showHidden` setting (`handlers.go`)
37+
- Command palette shell description updated to be platform-neutral (`commands.go`)
3638

3739
## [0.7.0] - 2026-08-04
3840

commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ func (a *App) getCommands() []commandItem {
624624
{"New directory", "Create a new directory", func() (tea.Model, tea.Cmd) {
625625
return a.startCreateDir()
626626
}},
627-
{"Open shell", "Open PowerShell in current directory", func() (tea.Model, tea.Cmd) {
627+
{"Open shell", "Open terminal shell in current directory", func() (tea.Model, tea.Cmd) {
628628
return a.openShell()
629629
}},
630630
{"Help", "Show help", func() (tea.Model, tea.Cmd) {

commands_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -958,13 +958,21 @@ func TestMoveFileDirectory(t *testing.T) {
958958
t.Error("source dir should not exist after moveFile")
959959
}
960960

961-
// Dest dir should exist with files
962-
content, err := os.ReadFile(filepath.Join(dstDir, "a.txt"))
961+
// Dest dir should exist with both files
962+
contentA, err := os.ReadFile(filepath.Join(dstDir, "a.txt"))
963963
if err != nil {
964964
t.Fatal(err)
965965
}
966-
if string(content) != "aaa" {
967-
t.Errorf("content = %q, want %q", string(content), "aaa")
966+
if string(contentA) != "aaa" {
967+
t.Errorf("a.txt content = %q, want %q", string(contentA), "aaa")
968+
}
969+
970+
contentB, err := os.ReadFile(filepath.Join(dstDir, "b.txt"))
971+
if err != nil {
972+
t.Fatal(err)
973+
}
974+
if string(contentB) != "bbb" {
975+
t.Errorf("b.txt content = %q, want %q", string(contentB), "bbb")
968976
}
969977
}
970978

handlers.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,22 @@ func (a *App) triggerPreview() tea.Cmd {
505505
a.previewReady = false
506506
a.previewLoading = true
507507
a.previewContent = ""
508+
showHidden := a.config.ShowHidden
508509
return func() tea.Msg {
509510
entries, err := os.ReadDir(item.Path)
510511
if err != nil {
511512
return PreviewResultMsg{path: item.Path, content: fmt.Sprintf("[Error: %v]", err)}
512513
}
514+
// Filter hidden files if not showing them
515+
if !showHidden {
516+
filtered := make([]os.DirEntry, 0, len(entries))
517+
for _, e := range entries {
518+
if !strings.HasPrefix(e.Name(), ".") {
519+
filtered = append(filtered, e)
520+
}
521+
}
522+
entries = filtered
523+
}
513524
var sb strings.Builder
514525
sb.WriteString(fmt.Sprintf("Directory: %s\n", item.Name))
515526
sb.WriteString(fmt.Sprintf("Items: %d\n\n", len(entries)))

handlers_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func TestTriggerPreviewDirectory(t *testing.T) {
7777
showPreview: true,
7878
width: 80,
7979
previewSvc: NewPreviewService(500),
80+
config: DefaultConfig(),
8081
}
8182

8283
cmd := app.triggerPreview()

0 commit comments

Comments
 (0)