Skip Menu |

This queue is for tickets about the IO-Prompter CPAN distribution.

Report information
The Basics
Id: 84165
Status: resolved
Priority: 0/
Queue: IO-Prompter

People
Owner: Nobody in particular
Requestors: victor.adam [...] derpymail.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: HISTORY_KEY, mysterious control input and verbatim tabs
Date: Sat, 23 Mar 2013 15:08:03 +0100
To: bug-io-prompter [...] rt.cpan.org
From: Victor ADAM <victor.adam [...] derpymail.org>
Howdy, 1) Although it is a documented feature, setting $ENV{IO_PROMPTER_(HISTORY|COMPLETE)_KEY} produces unexpected results. For example: BEGIN { $ENV{IO_PROMPTER_HISTORY_KEY} = "\cA\cZ" } use IO::Prompter; prompt; prompt; Hitting either Ctrl-a or Ctrl-z on the second prompt will cause IO::Prompter to complain loudly: Show quoted text
> Use of uninitialized value $mode in pattern match (m//) at
/home/grimy/perl/lib/site_perl/5.16.2/IO/Prompter.pm line 1275. Use of uninitialized value $mode in pattern match (m//) at /home/grimy/perl/lib/site_perl/5.16.2/IO/Prompter.pm line 1281. Use of uninitialized value $mode in pattern match (m//) at /home/grimy/perl/lib/site_perl/5.16.2/IO/Prompter.pm line 1296. This is because $next is compared to $completion_type using a simple string ne, which incorrectly assumes that $completion_type is always a single character. Using characters that are special inside regex character classes also produces strange behaviour, because the environment variable are interpolated without quotemeta. 2) The name of any unrecognized control character are echoed. This undocumented, untested "feature" is especially annoying when holding down backspace: once all input has been erased, it will print "ERASE" repeatedly, like so: Show quoted text
> ERASE
ERASE ERASE It looks like this was only meant for debugging purposes, and should be removed. 3) Verbatim tabs mix /very/ poorly with moving the cursor and/or erasing. For example, here is the result of hitting Ctrl-v TAB a Ctrl-v TAB Ctrl-b Ctrl-b Ctrl-b: Show quoted text
> a a a a
The simplest workaround is to echo simple spaces instead of tabs. A contextual diff implementing all three bugfixes follows. It passes regression tests successfully. Your young apprentice, Victor Adam --- Prompter.old 2013-03-06 10:19:56.000000000 +0100 +++ Prompter.pm 2013-03-23 14:31:31.128213892 +0100 @@ -24,7 +24,7 @@ my $COMPLETE_NEXT = qq{\cN}; my $COMPLETE_PREV = qq{\cP}; -my $COMPLETE_INIT = qr{ [$COMPLETE_KEY$COMPLETE_HIST] }xms; +my $COMPLETE_INIT = qr{ [\Q$COMPLETE_KEY$COMPLETE_HIST\E] }xms; my $COMPLETE_CYCLE = qr{ [$COMPLETE_NEXT$COMPLETE_PREV] }xms; my %COMPLETE_MODE = ( @@ -414,7 +414,7 @@ -style => sub{ q{} }, -nostyle => sub{ q{} }, -echostyle => sub{ q{} }, - -echo => sub { shift }, + -echo => sub { my $char = shift; $char eq "\t" ? q{ } : $char }, -return => sub { "\n" }, ); @@ -1247,8 +1247,8 @@ state $completion_prefix; # ...skipped before completing # Track completion type and level (switch if necessary)... - if ($next =~ $COMPLETE_INIT && $next ne $completion_type) { - $completion_type = $next; + if ($next =~ $COMPLETE_INIT && index($completion_type, $next) < 0) { + $completion_type = index($COMPLETE_KEY, $next) >= 0 ? $COMPLETE_KEY : $COMPLETE_HIST; $completion_level = 1; } else { @@ -1258,7 +1258,7 @@ # If starting completion, cache completions... if ($completion_level == 1) { ($completion_prefix, @completion_list) - = $next eq $COMPLETE_KEY + = index($COMPLETE_KEY, $next) >= 0 ? _current_completions_for($input, $opt_ref) : _current_history_for($input, $opt_ref); @completion_ring = (@completion_list, q{}); @@ -1477,8 +1477,6 @@ # Not verbatim after mysterious ctrl input... $prev_was_verbatim = 0; - say grep { $ctrl{$_} eq $next } keys %ctrl; - next INPUT; } }

Message body is not shown because sender requested not to inline it.

Subject: Re: [rt.cpan.org #84165] HISTORY_KEY, mysterious control input and verbatim tabs
Date: Sun, 24 Mar 2013 21:40:25 +0000
To: bug-IO-Prompter [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Thanks, Victor. I'll look at integrating these useful fixes as soon as I can. (Probably within a week or so, but I can't be sure) Very much appreciated! Damian