zsh-workers
 help / color / mirror / code / Atom feed
* INTERACTIVE_COMMENTS regression
@ 2018-01-24 13:50 ` İsmail Dönmez
  2018-01-24 14:21   ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: İsmail Dönmez @ 2018-01-24 13:50 UTC (permalink / raw)
  To: zsh-workers

Hi,

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.

Regards,
ismail


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: INTERACTIVE_COMMENTS regression
  2018-01-24 13:50 ` INTERACTIVE_COMMENTS regression İsmail Dönmez
@ 2018-01-24 14:21   ` Peter Stephenson
  2018-01-25 10:14     ` İsmail Dönmez
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2018-01-24 14:21 UTC (permalink / raw)
  To: zsh-workers

On Wed, 24 Jan 2018 14:50:23 +0100
İsmail Dönmez <ismail@i10z.com> 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;
 };
 
 /*


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: INTERACTIVE_COMMENTS regression
  2018-01-24 14:21   ` Peter Stephenson
@ 2018-01-25 10:14     ` İsmail Dönmez
  0 siblings, 0 replies; 3+ messages in thread
From: İsmail Dönmez @ 2018-01-25 10:14 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

On Wed, Jan 24, 2018 at 3:21 PM, Peter Stephenson
<p.stephenson@samsung.com> wrote:
> On Wed, 24 Jan 2018 14:50:23 +0100
> İsmail Dönmez <ismail@i10z.com> 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;
>  };
>
>  /*

That fixes the problem, thanks!

ismail


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-25 10:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20180124135136epcas4p439d2f18c7ec7dedc59b660c2daafdbd6@epcas4p4.samsung.com>
2018-01-24 13:50 ` INTERACTIVE_COMMENTS regression İsmail Dönmez
2018-01-24 14:21   ` Peter Stephenson
2018-01-25 10:14     ` İsmail Dönmez

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).