Skip to content

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

@k2s

Description

@k2s

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions