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

Cursor jumps to second line if enter is pressed before fzy starts #81

Closed
neuschaefer opened this issue Jun 16, 2018 · 1 comment
Closed

Comments

@neuschaefer
Copy link
Contributor

Hi,
I sometimes enter a search pattern (and press enter) faster than fzy starts up. I'd expect the first result to be selected in that case, but instead, the cursor moves to the second line.

Test case:

$ (echo a; echo b; echo c; sleep 1) | fzy<enter><enter>

I realize that this is because the code for CTRL-J is the same as '\n'. After fzy starts up, the enter key mapped to '\r', via termios.

Thus, a solution would involve:

  1. Reading the input once, non-blockingly; preferably before the terminal is configured with termios, to avoid false conversions from CTRL-J to '\r'
  2. Replacing all occurences of '\n' with '\r' in the early input
  3. Feeding the converted early input into the input state machine

I'm not sure the added complexity would be justified, so perhaps take this issue as the beginning of a discussion, rather than a bug report or feature request.

neuschaefer added a commit to neuschaefer/fzy that referenced this issue Jun 16, 2018
jhawthorn added a commit that referenced this issue Jun 17, 2018
It's possible for user input to arrive while fzy was still reading
choices from stdin. Previously, this would happen before the correct
termios were set, causing fzy to misinterpret Enter as Ctrl-J for
example.

Fixes #81
@jhawthorn
Copy link
Owner

Thanks for the report! I definitely want to fix this.

I have an alternate solution in #85, where I initialize the tty (which configures the termios) before reading in choices. (It's still technically possible that user input comes in before we initialize the tty, but I think it will probably never happen in practice)

Would you mind giving that a try @neuschaefer ?

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