Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering panic #826

Open
guidoenr opened this issue Sep 22, 2023 · 1 comment
Open

Filtering panic #826

guidoenr opened this issue Sep 22, 2023 · 1 comment

Comments

@guidoenr
Copy link

guidoenr commented Sep 22, 2023

Hey guys, how are you? hope you're doing good :)

We are using your model to display an application to handle tests jobs, which are listed in the dash view in the following way:

When i type / to enter a filter value and then fill it with some text:

I got the following error:

panic: runtime error: invalid memory address or nil pointer dereference                                                                                            
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x5e4508]

goroutine 861 [running]:
github.com/charmbracelet/bubbles/list.filterItems.func1()
	/home/guido/go/pkg/mod/github.com/charmbracelet/bubbles@v0.16.1/list/list.go:1211 +0x1a8
github.com/charmbracelet/bubbletea.(*Program).handleCommands.func1.1()
	/home/guido/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.24.2/tea.go:268 +0x38
created by github.com/charmbracelet/bubbletea.(*Program).handleCommands.func1
	/home/guido/go/pkg/mod/github.com/charmbracelet/bubbletea@v0.24.2/tea.go:267 +0x14d

Checking the stacktrace seems to be an error at the moment of playing with the list.

I would like to know if there are some examples of how to filter structs.

for example:

type oneStruct struct{
   string name
   int64 id
}

(filtering by their name)

And I think this could be the cause of the error, maybe the Filter interface implementation is not working.

Searched at https://github.com/charmbracelet/bubbletea/tree/master/examples and also tried #155 but didn't work

@muesli
Copy link
Member

muesli commented Mar 1, 2024

The list's Item interface defines a FilterValue function that you can implement to allow for filtering custom structs and elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants