Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Ctrl-c not working during correction with 5.1



On Wed, 2 Sep 2015 15:10:43 +0200
Christian Neukirchen <chneukirchen@xxxxxxxxx> wrote:
> zsh 5.1 (x86_64-unknown-linux-gnu)
> zsh-5.1-0-g11189c6
> % zsh -f
> juno% setopt NOALWAYSLASTPROMPT PROMPT_SUBST
> juno% PS1='$(echo foo)%# '
> foo% ls /usr/share/man/man1/<PRESS TAB HERE>
> zsh: do you wish to see all 2528 possibilities (1264 lines)? <PRESS ^C HERE>n
> $(echo ls /usr/share/man/man1/
> foo% 
> 
> Somehow the unevaluated PS1 is printed.

I see what's happened --- in the old days we reset the error flag which
cancelled both an error and interrupt; now it only cancels an error.
However, this is one of the small number of special places where we
don't want an interrupt to take us back to the original prompt --- it
should simply cancel the query and redraw the line.

I think if we do have an error or interrupt we should not be executing
the recursive zrefresh() that was causing the bad prompt; that would
have meant the interrupt took us back to a new prompt, which would
presumably be the correct behaviour if we *didn't* reset the interrupt.
I've added that, but I don't know anywhere the difference is visible
now.

pws

diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 78046fb..0c28c0a 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -1761,7 +1761,8 @@ singlelineout:
 	inlist = 1;
 	listmatches();
 	inlist = 0;
-	zrefresh();
+	if (!errflag)
+	    zrefresh();
     }
     if (showinglist == -1)
 	showinglist = nlnct;
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index d1d3206..9751f7a 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1183,6 +1183,11 @@ getzlequery(void)
 
     /* get a character from the tty and interpret it */
     c = getfullchar(0);
+    /*
+     * We'll interpret an interruption here as only interrupting the
+     * query, not the line editor.
+     */
+    errflag &= ~ERRFLAG_INT;
     if (c == ZWC('\t'))
 	c = ZWC('y');
     else if (ZC_icntrl(c) || c == ZLEEOF)



Messages sorted by: Reverse Date, Date, Thread, Author