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

Unable to enter a single-digit -ve argument #359

Closed
haridsv opened this issue Jul 24, 2016 · 6 comments
Closed

Unable to enter a single-digit -ve argument #359

haridsv opened this issue Jul 24, 2016 · 6 comments

Comments

@haridsv
Copy link
Contributor

haridsv commented Jul 24, 2016

In readline, to enter a -ve argument, you start with <Esc> followed by -, which immediately defaults to -1 as the argument ((arg: -1)), but as soon as you enter a digit, say 5, the argument changes to -5 ((arg: -5)). The same sequence in prompt-toolkit results in an argument of -15 with no way to enter -5 as argument.

@haridsv
Copy link
Contributor Author

haridsv commented Jul 24, 2016

Actually, readline's behaves is a little more complex when used with Alt. After starting a -ve argument, if you continue entering digits with the combination of Alt, they immediately get appended (like the current behavior in prompt-toolkit). I.e., Alt- followed by Alt-5 will result in -15. Even Alt--5 without releasing Alt in between - and 5 results in -15, but if you release Alt in between (i.e., Alt-- followed by 5) will result in -5.

Do we want to emulate this as is in prompt-toolkit? I have a patch working that doesn't take this difference into account. It can probably be extended, if the state of Alt can be detected. @jonathanslenders

@haridsv
Copy link
Contributor Author

haridsv commented Jul 24, 2016

Actually, there is more to this, if we really want to emulate closely with readline. In readline, once you start entering an argument, you no longer have to keep Alt pressed, so it basically enters into a different mode (like a search mode) that continues consuming digits. This can however be addressed as a separate feature and is also backwards incompatible, in case some prompt-toolkit applications already started relying on this lack of distinct mode.

@jonathanslenders
Copy link
Member

Hi @haridsv,

Thanks a lot for the extensive explanation, that was really helpful. I think in the last few commits, I fixed this and made it readline compatible. Can you please check whether everything works like you think it should?

Thanks,
Jonathan

@haridsv
Copy link
Contributor Author

haridsv commented Aug 13, 2016

Apologies for the delay in trying this out. I just pulled the latest and tried to use it with IPython. I immediately noticed that there is a big regression here. E.g., I can no longer type anything but a single digit as an argument. The moment I try to enter a second digit (with or without Alt pressed), the input is taken literally and the argument that was entered so far gets ignored. The only thing that works better is entering a -ve argument when Alt is key is released for further digits. In this case, the specific issue reported here is fixed and I am able to enter a single digit -ve argument (i.e., Alt-- followed by 3 results in -3 as expected). However, this too gets aborted (just like for +ve argument) if I keep Alt key pressed (i.e., Alt-- followed by Alt-3 results in literal 3).

@jonathanslenders
Copy link
Member

Hi @haridsv,

This should be fixed in: 5acd332
Can you try again by pulling the latest master branch?
Thanks a lot!

@haridsv
Copy link
Contributor Author

haridsv commented Aug 15, 2016

Yes, it is working as expected now. The only other difference I see compared to readline is when you have Alt pressed for entering -ve numbers. I.e., Alt-- followed by Alt-2 results in -12 as the argument (which is different from what you get for Alt-- followed by 2). In prompt-toolkit, you get -2 in both cases. I don't however think it is important enough to match.

@haridsv haridsv closed this as completed Aug 15, 2016
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