Re: [PATCH 2/2] In add --patch, Handle K,k,J,j slightly more gracefully.
William Pursell <bill.pursell@gmail.com> writes:
> Instead of printing the help menu, this will print
> "No next hunk" and then process the given hunk again.
> ---
> - elsif ($other =~ /K/ && $line =~ /^K/) {
> - $ix--;
> + elsif ( $line =~ /^K/) {
> + $other =~ /K/ ? $ix-- : print STDERR "No previous hunk\n";This may be cute but I think it is harder to read than necessary.
if ($other =~ /K/) {
$ix--;
} else {
print STDERR "No previous hunk\n";
}Show 20 quoted lines
> + elsif ($line =~ /^k/) {
> + if ($other =~ /k/) {
> + while (1) {
> + $ix--;
> + last if (!$ix ||
> + !defined $hunk[$ix]{USE});
> + }
> + next;
> + }
> + else {
> + print STDERR "No previous hunk\n";
> }
> - next;
> }
> + elsif ($line =~ /^j/) {
> + if ($other !~ /j/) {
> + print STDERR "No next hunk\n";
> + next;
> }
> }Doesn't this behave differently against an unavailable 'k' and 'j'? When the user says 'j' when no next hunk is available, it will ask again about that hunk, but when the user says 'k' at the first hunk, because you discarded 'next', it will ask about the next hunk, no? Shouldn't it ask again about the same hunk, against which the user gave an erroneous input?