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.11k stars 283 forks source link

Command mode is broken in latest master #400

Closed gwjo closed 3 years ago

gwjo commented 3 years ago

In the latest master (195f8502049c63fc2a45c7fd3d498257489ff076) the running of an arbitrary command (via the c key) does not work.

For example, below I've entered the cat command:

echo ".bashrc" | fpp
executing command:
b'cat' '.bashrc'

Command 'bcat' not found.

It appears the entered command is not getting converted from bytes to a string, so a leading "b" is added to whatever command is entered.

As far as I can tell these appears to have been introduced by #392 and I can fix this by converting the command to a utf-8 string in show_and_get_command before returning, changing this:

https://github.com/facebook/PathPicker/blob/195f8502049c63fc2a45c7fd3d498257489ff076/src/pathpicker/screen_control.py#L595

To this:

        return str(self.stdscr.getstr(begin_height + 3, 0, max_x), 'utf-8')

But not sure if that is the "correct" fix or not.

KapJI commented 3 years ago

Fixed, thank you! 🎉