zsh-workers
 help / color / mirror / code / Atom feed
From: "İsmail Dönmez" <ismail@i10z.com>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: zsh-workers@zsh.org
Subject: Re: INTERACTIVE_COMMENTS regression
Date: Thu, 25 Jan 2018 11:14:46 +0100	[thread overview]
Message-ID: <CAMAzfTgaA8dkW4_U95c4yrZNUuu39_y6bZxR4TDCysQZD2fcXA@mail.gmail.com> (raw)
In-Reply-To: <20180124142102.7722a1d8@pwslap01u.europe.root.pri>

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


      reply	other threads:[~2018-01-25 10:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180124135136epcas4p439d2f18c7ec7dedc59b660c2daafdbd6@epcas4p4.samsung.com>
2018-01-24 13:50 ` İsmail Dönmez
2018-01-24 14:21   ` Peter Stephenson
2018-01-25 10:14     ` İsmail Dönmez [this message]

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=CAMAzfTgaA8dkW4_U95c4yrZNUuu39_y6bZxR4TDCysQZD2fcXA@mail.gmail.com \
    --to=ismail@i10z.com \
    --cc=p.stephenson@samsung.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).