facebook / PathPicker

PathPicker accepts a wide range of input -- output from git commands, grep results, searches -- pretty much anything. After parsing the input, PathPicker presents you with a nice UI to select which files you're interested in. After that you can open them in your favorite editor or execute arbitrary commands.
https://facebook.github.io/PathPicker/
MIT License
5.12k stars 282 forks source link

Infinite loop when selecting entry with certain width relative to window width #426

Open jpalus opened 2 years ago

jpalus commented 2 years ago

Entries which end close to window border PathPicker cause infinite loop after trying to select them with either f or F.

Following for loop is affected: https://github.com/facebook/PathPicker/blob/cc032b2b2fa2fa8ab2fedc93766b2bf2303781d2/src/pathpicker/screen_control.py#L668-L673

Seemingly due to reaching this code path: https://github.com/facebook/PathPicker/blob/cc032b2b2fa2fa8ab2fedc93766b2bf2303781d2/src/pathpicker/line_format.py#L300-L306

Which apparently keeps adding dirty indexes forever: https://github.com/facebook/PathPicker/blob/cc032b2b2fa2fa8ab2fedc93766b2bf2303781d2/src/pathpicker/line_format.py#L237-L238

jpalus commented 2 years ago

Reproduces for me with:

$ mkdir test-git
$ cd test-git
$ git init
# create file with name long enough relative to window width
$ echo test > $(printf 'f%.0s' `seq $(($(tput cols) - 10))`).txt
$ git status | fpp
# try to select file with 'F'