charmbracelet / charmbracelet/bubbletea

filepicker: panic on rename/delete of file that is in filepicker list

Open
#1,434 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
44.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
If you rename or delete file that is listed with filepicker module it will panic and there is no way to handle it correctly.

I am working on MacOS.

I tried to add recover to my View(), but then there is no way to re-render the view and the page will be blank.

```go
func (m model) View() string {
defer func() {
if r := recover(); r != nil {
fmt.Fprintln(os.Stderr, "Caught panic in filepicker.View:", r)
// recreate filepicker
m.setupFilePicker()
// TODO how to force tea to redraw the view after panic?
}
}()

// ....
```

**To Reproduce**
Steps to reproduce the behavior:
1. create file `test.txt` in home
2. run `examples/file-picker/main.go`, you will see list of files in your home
3. rename or delete file `test.txt` you created with file manager or shell
4. press arrow key down to move in the list
5. the example will panic

**Expected behavior**
It should not crash, or there should be at least possibility to handle this panic in tea view.

Contributor guide

Open the contributing guide

Research direction

Start with examples/file-picker/main.go and reproduce the panic by renaming or deleting a listed file, then pressing the down arrow. Trace how the filepicker handles the changed list; done means the example no longer panics and the view remains usable after the file is renamed or deleted.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.