From 459e5619a78265a8281b76b5d7017aab1a9e5002 Mon Sep 17 00:00:00 2001 From: Juerd Waalboer Date: Wed, 12 Jul 2023 22:02:59 +0200 Subject: [PATCH] Place cursor at start of rejected input instead of end The cursor was placed after the rejected input, both to indicate where the mistake was, and to make it easy to it out. But since "retry" is only used when there are trailing words, that means the cursor would be placed on the space between the mistake and the trailing input. By putting it at the first character of the rejected input, it is less visually ambiguous. The user can now use instead of . --- revbank | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/revbank b/revbank index 6e8d15e..ff910b6 100755 --- a/revbank +++ b/revbank @@ -82,11 +82,11 @@ sub prompt($prompt, $plugins, $completions) { }); if ($retry) { - my $preset = join " ", @retry[0 .. $#retry - 1]; - my $cursor = length $preset; - $preset .= " " . join " ", @{ $retry[-1] }; - $readline->insert_text($preset); - $readline->Attribs->{point} = $cursor; + my $trailing = "@{ pop @retry }"; + my $rejected = pop @retry; + my $accepted = "@retry"; + $readline->insert_text("$accepted $rejected $trailing"); + $readline->Attribs->{point} = 1 + length $accepted; @retry = (); $retry = 0; }