Skip to content

Commit

Permalink
fix: panic on empty directories
Browse files Browse the repository at this point in the history
  • Loading branch information
ALX99 committed May 18, 2024
1 parent 02bb2b6 commit ae406a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/models/main_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case m.cfg.Settings.Keymap.NavOut:
return m, m.loadDir(path.Dir(m.cwd))
case m.cfg.Settings.Keymap.NavIn:
if m.files != nil && m.files[m.cursorOffset()].IsDir() {
if len(m.files) > 0 && m.files[m.cursorOffset()].IsDir() {
return m, m.loadDir(path.Join(m.cwd, m.files[m.cursorOffset()].Name()))
}
case m.cfg.Settings.Keymap.NavHome:
return m, m.loadDir(os.Getenv("HOME"))
// case "d":

}
case tea.WindowSizeMsg:
var fName string
if m.files != nil && len(m.files) > 0 {
if len(m.files) > 0 {
fName = m.files[m.cursorOffset()].Name()
}

Expand Down

0 comments on commit ae406a2

Please sign in to comment.