zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: [BUG] With CORRECT_ALL, an interrupted correct puts a truncated entry in history
Date: Mon, 4 Dec 2023 20:10:10 -0800	[thread overview]
Message-ID: <CAH+w=7bZmryKWV6=kZhMU7=R9WPa+sFEFi1iJcybcJsnjw15_g@mail.gmail.com> (raw)
In-Reply-To: <20231205021217.GA357346@zira.vinc17.org>

[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]

On Mon, Dec 4, 2023 at 6:12 PM Vincent Lefevre <vincent@vinc17.net> wrote:
>
> zira% setopt CORRECT_ALL
> zira% echo fil && true
> zsh: correct 'fil' to 'file' [nyae]?
>
> Here, type Ctrl-C to interrupt.
>
> "echo fil" shouldn't have been put in the history.

What's happening here is that the corrections occur in-place as the
parser reads words from the input line, much the same way that aliases
are expanded.

When you hit ctrl-c you cause an interrupt signal which stops the
parser from reading any further input, but because it's interactive
the shell itself doesn't exit, it just forces the parser to return.
The history mechanism then records what the parser read so far.

Conversely when you hit e.g. 'a' the parser is not interrupted,
continues to the end of the line, and then returns.  Again the history
mechanism records what the parser read so far.

Changing this would potentially require changing the way the
lexer+parser handle interrupt signals in general ... or changing both
^C and 'a' to skip the history, I suspect.

> BTW, the behavior in case of several spelling corrections should
> be documented.

Something like this?

[-- Attachment #2: correctall.txt --]
[-- Type: text/plain, Size: 1147 bytes --]

diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index cbd3d0f8e..c3af8dd33 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -1214,6 +1214,9 @@ Note that, when the tt(HASH_LIST_ALL) option is not set or when some
 directories in the path are not readable, this may falsely report spelling
 errors the first time some commands are used.
 
+Refer to the shell variable tt(SPROMPT) for an explanation of the
+`tt([nyae])' (no/yes/abort/edit) prompt that is offered.
+
 The shell variable tt(CORRECT_IGNORE) may be set to a pattern to
 match words that will never be offered as corrections.
 )
@@ -1222,7 +1225,10 @@ pindex(NO_CORRECT_ALL)
 pindex(CORRECTALL)
 pindex(NOCORRECTALL)
 item(tt(CORRECT_ALL) (tt(-O)))(
-Try to correct the spelling of all arguments in a line.
+Try to correct the spelling of all arguments in a line, in order from
+left to right, treating each as a file name.  Answering `tt(a)' or
+`tt(e)' at any prompt stops all corrections, otherwise every correction
+is prompted for.
 
 The shell variable tt(CORRECT_IGNORE_FILE) may be set to a pattern to
 match file names that will never be offered as corrections.

  reply	other threads:[~2023-12-05  4:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-05  2:12 Vincent Lefevre
2023-12-05  4:10 ` Bart Schaefer [this message]
2023-12-05 12:57   ` Vincent Lefevre
2023-12-05 21:22     ` Bart Schaefer
2023-12-06 15:03       ` Vincent Lefevre
2023-12-09 21:44         ` Bart Schaefer
2023-12-17 13:54           ` Vincent Lefevre
2023-12-17 19:37             ` Bart Schaefer
2023-12-18  3:37               ` Vincent Lefevre
2023-12-18  6:36                 ` Bart Schaefer
2024-01-21  5:06     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7bZmryKWV6=kZhMU7=R9WPa+sFEFi1iJcybcJsnjw15_g@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).