Skip to content

Commit e8aff06

Browse files
committed
fix: let 'h' work only when arg was file
Signed-off-by: shane.xb.qian <[email protected]>
1 parent c98050b commit e8aff06

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ui/ui.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,17 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
246246
return m, tea.Quit
247247

248248
case "left", "h", "delete":
249-
yes, _ := utils.StdinIsPipe()
250-
if m.state == stateShowDocument && !yes {
249+
isPipe, _ := utils.StdinIsPipe()
250+
path := m.common.cfg.Path
251+
if path == "" {
252+
path = "."
253+
}
254+
isDir := false
255+
info, err := os.Stat(path)
256+
if err == nil && info.IsDir() {
257+
isDir = true
258+
}
259+
if m.state == stateShowDocument && !isPipe && isDir {
251260
cmds = append(cmds, m.unloadDocument()...)
252261
return m, tea.Batch(cmds...)
253262
}

0 commit comments

Comments
 (0)