Closed aspyct closed 1 year ago
I'll be having a look at it as soon as possible. HighLine dates from a time where all the hard work should be done by it. This is probably an issue related to the fact that HighLine is handling all cases related to special characters like backspace and others. If you come up with a PR, feel free to open it, I would be thankful! If not possible, just wait some time and I will surely try to fix it.
Thanks for reporting the issue! 👍
Hi,
No worries, this isn't in any way a blocking/problematic bug, so don't feel pressed to fix this :) I might look into it on the train sometime, but no promises here :)
I've just run into this as well - we can work around it for now, and if I have time for a PR I'll raise one, but also subscribing for notifications if you happen to fix it before I do. Cheers!
io/console #getpass handles ctrl-C correctly
Just a thought, you could always throw the exit in with the character checks in HighLine#get_line_raw_no_echo_mode, this would "catch" (I say that because trap
doesn't seem to catch anything in the method, or anywhere for that matter). This worked for me. I am not sure off hand if \u0003 is going to be cross platform but it seems to work in POSIX environments, tested on macOS:
diff --git a/lib/highline.rb b/lib/highline.rb
index 3e60cd3..e33e13a 100755
--- a/lib/highline.rb
+++ b/lib/highline.rb
@@ -538,6 +538,7 @@ class HighLine
terminal.raw_no_echo_mode_exec do
loop do
character = terminal.get_character
+ exit 130 if character == "\u0003"
break unless character
break if ["\n", "\r"].include? character
Thanks for your suggestion @Faheetah Sorry for the long wait. I've just opened a PR for it #259
Hi,
Just noticed something a little odd with the handling of a ctrl-c while in an
ask
with echo set to false.Two things happened here:
q.echo
is not set to false)I'm using highline-2.0.0.gem, and
zsh
in the standard terminal app in OSX.