Problem using 'execute' action invoked via HTTP POST-request
Checklist
- [x] I have read through the manual page (
man fzf) - [x] I have searched through the existing issues
- [x] For bug reports, I have checked if the bug is reproducible in the latest version of fzf
Output of fzf --version
0.65 (devel)
OS
- [x] Linux
- [ ] macOS
- [ ] Windows
- [ ] Etc.
Shell
- [ ] bash
- [x] zsh
- [ ] fish
Problem / Steps to reproduce
This is a mininal reproducible example for my problem:
touch ~/some_file
echo -n "Some\nrandom\nitems\ndoesn't\nmatter" | fzf --listen=12345 --bind="F1:execute:curl -X POST -d 'execute:less ~/some_file' http://localhost:12345"
When pressing a binded key (F1 in example), pager will open as expected, but first key will go not to the pager, but to fzf. E.g., if your first keypress in pager will be q, it'wont close - second q press will, but first q will will be added to prompt.
Using zsh + alacritty, it's always reproducible with and without tmux.
P.S. Even if I'm making first keypress after delay of 5-10 seconds, it will still go through pager straight into fzf.
Yeah, I can see this happening. fzf uses a blocking I/O to read a keystroke from the user device, and as far as I know, this call can't be interrupted. So if execute is triggered by an external event rather than a key event, that blocking call from fzf will intercept one key. Any delay won't help.
So if we want to fix this, we would have to replace the blocking I/O with a non-blocking I/O in a loop, which is not ideal. I currently don't have a better idea.
Somewhat related issue on Windows: #4260