TaKO8Ki / gobang

A cross-platform TUI database management tool written in Rust
MIT License
2.82k stars 90 forks source link

adding is_empty flag for prevent panic #145

Open kyoto7250 opened 2 years ago

kyoto7250 commented 2 years ago

close #142

This bug is caused by a moving ownership in a closure.

https://github.com/TaKO8Ki/gobang/blob/b13e4bb255ea533db16240e1cb5138fca4241264/src/components/completion.rs#L77-L83

I think if ListState is hidden and input is down or up arrow, then the ListState is not updated, and try to acccess to already moved variable again.

However, I didn't see a problem with the current closure implementation, so I responded by adding a flag to not call the closure if ListState is not displayed.

Thank you in advance.

changelog: Adding is_empty flag for prevent panic.