Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: INTERACTIVE_COMMENTS regression
- X-seq: zsh-workers 42322
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: INTERACTIVE_COMMENTS regression
- Date: Wed, 24 Jan 2018 14:21:02 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180124142109euoutp023dfb592daadd24b2c06aa6e4c71d0cc5~MxObDVCyI3275132751euoutp02x
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1516803669; bh=B/vG2yKX02TcGO24g+ZVjuq7Zbqa45QGpR7h/hhDA14=; h=Date:From:To:Subject:In-reply-to:References:From; b=F/cNpd7dvz8Q+SDLyLGyPPVHtrLirDmG76HVj+ydvUpSVlOg8MoG2XIwK2DCdxETe FdmbI6M0fHawY334Hpg6IO9VWAdlVYCrpdr8hhkROne/ig10lassv7zPpw7J/TSo15 ENkpBdDCPj1E38sOBQtPmbnVteuoRZu+5wx0Y28c=
- In-reply-to: <CAMAzfThpZJJDc8ZoOTpXYM0YfAND4Uox6Z3gQLZdEJc1jO4F0g@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: Samsung Cambridge Solution Centre
- References: <CGME20180124135136epcas4p439d2f18c7ec7dedc59b660c2daafdbd6@epcas4p4.samsung.com> <CAMAzfThpZJJDc8ZoOTpXYM0YfAND4Uox6Z3gQLZdEJc1jO4F0g@mail.gmail.com>
On Wed, 24 Jan 2018 14:50:23 +0100
İsmail Dönmez <ismail@xxxxxxxx> wrote:
> With the latest git head:
>
> ~ > setopt INTERACTIVE_COMMENTS
> ~ > # ls
> <Press up arrow in keyboard>
> ~ > setopt INTERACTIVE_COMMENT
>
> Looks like comment is getting lost, tested the same config with zsh
> 5.3.1 and it works fine.
This isn't particularly elegant but it ought to do the trick.
(Although when I commit it I might change the name of the
variable to "hist_keep_comment" for clarity, come to think of it.)
pws
diff --git a/Src/hist.c b/Src/hist.c
index e08984f..76c3df4 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -204,6 +204,9 @@ int hlinesz;
static zlong defev;
+/* Flag that line was aborted but we want to keep it even if no words */
+static int hist_aborted;
+
/* Remember the last line in the history file so we can find it again. */
static struct histfile_stats {
char *text;
@@ -258,6 +261,7 @@ hist_context_save(struct hist_stack *hs, int toplevel)
hs->addtoline = addtoline;
hs->hlinesz = hlinesz;
hs->defev = defev;
+ hs->hist_aborted = hist_aborted;
/*
* We save and restore the command stack with history
* as it's visible to the user interactively, so if
@@ -303,6 +307,7 @@ hist_context_restore(const struct hist_stack *hs, int toplevel)
addtoline = hs->addtoline;
hlinesz = hs->hlinesz;
defev = hs->defev;
+ hist_aborted = hs->hist_aborted;
if (cmdstack)
zfree(cmdstack, CMDSTACKSZ);
cmdstack = hs->cstack;
@@ -1462,7 +1467,7 @@ hend(Eprog prog)
} else
save = 0;
}
- if (chwordpos <= 2)
+ if (chwordpos <= 2 && !hist_aborted)
save = 0;
else if (should_ignore_line(prog))
save = -1;
@@ -1565,6 +1570,7 @@ hend(Eprog prog)
*/
while (histsave_stack_pos > stack_pos)
pophiststack();
+ hist_aborted = 0;
unqueue_signals();
return !(flag & HISTFLAG_NOEXEC || errflag);
}
@@ -1591,6 +1597,7 @@ ihwabort(void)
{
if (chwordpos%2)
chwordpos--;
+ hist_aborted = 1;
}
/* add a word to the history List */
diff --git a/Src/zsh.h b/Src/zsh.h
index ba2f8cd..8bc0125 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2997,6 +2997,7 @@ struct hist_stack {
void (*addtoline) _((int));
unsigned char *cstack;
int csp;
+ int hist_aborted;
};
/*
Messages sorted by:
Reverse Date,
Date,
Thread,
Author