gdu icon indicating copy to clipboard operation
gdu copied to clipboard

Error When Pressing Right Key in Empty Folder: Panic with Interface Conversion Nil Error

Open ShivamB25 opened this issue 1 year ago • 0 comments

Description

When using the gdu Linux program and navigating through the UI, I encountered a panic error that seems to be related to the right key press action. The error message indicates an issue with converting interfaces.

Steps to Reproduce

  1. Launch the gdu program.
  2. Navigate to a folder that doesn't contain any subfolders or files.
  3. Press the right arrow key.

Expected Behavior

I expect the gdu program to gracefully handle the right arrow key press even in folders without subfolders or files, without triggering any errors.

Actual Behavior

Instead of proceeding smoothly, the program throws a panic error with the following stack trace:

panic: interface conversion: interface is nil, not fs.Item [recovered]
        panic: interface conversion: interface is nil, not fs.Item

goroutine 1 [running]:
github.com/rivo/tview.(*Application).Run.func1()
        github.com/rivo/tview/application.go:243 +0x4d
panic({0x894e40, 0xc0002dc270})
        runtime/panic.go:838 +0x207
github.com/dundee/gdu/v5/tui.(*UI).fileItemSelected(0xc0002d21a0, 0xffffffffffffffff?, 0x1?)
        github.com/dundee/gdu/v5/tui/tui.go:207 +0xb0
github.com/dundee/gdu/v5/tui.(*UI).handleRight(0xc0002d21a0?)
        github.com/dundee/gdu/v5/tui/keys.go:218 +0xa5
github.com/dundee/gdu/v5/tui.(*UI).handleLeftRight(0xc0002d21a0?, 0xc000020020?)
        github.com/dundee/gdu/v5/tui/keys.go:128 +0x4c
github.com/dundee/gdu/v5/tui.(*UI).keyPressed(0xc0002d21a0, 0xc0000c5918?)
        github.com/dundee/gdu/v5/tui/keys.go:39 +0x3f6
github.com/rivo/tview.(*Application).Run(0xc0002d8000)
        github.com/rivo/tview/application.go:318 +0x782
github.com/dundee/gdu/v5/tui.(*UI).StartUILoop(0xc0002da000?)
        github.com/dundee/gdu/v5/tui/tui.go:184 +0x22
github.com/dundee/gdu/v5/cmd/gdu/app.(*App).Run(0xc0002da000)
        github.com/dundee/gdu/v5/cmd/gdu/app/app.go:162 +0x25c
main.runE(0xc3fc60?, {0xc0000a1570, 0x1, 0x1})
        github.com/dundee/gdu/v5/cmd/gdu/main.go:195 +0x825
github.com/spf13/cobra.(*Command).execute(0xc3fc60, {0xc0000b8010, 0x1, 0x1})
        github.com/spf13/cobra/command.go:856 +0x67c
github.com/spf13/cobra.(*Command).ExecuteC(0xc3fc60)
        github.com/spf13/cobra/command.go:974 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
        github.com/spf13/cobra/command.go:902
main.main()
        github.com/dundee/gdu/v5/cmd/gdu/main.go:199 +0x25```

### Additional Information
- `gdu` Version: [Provide the version of the program you're using]
- Operating System: linux_amd64_ubuntu23.04
- Terminal Environment: zsh + ohmyzsh

ShivamB25 avatar Aug 21 '23 19:08 ShivamB25