zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: <zsh-workers@zsh.org>
Subject: Re: Proposal (with code) to fix breaking of history widgets on reset-prompt
Date: Thu, 28 Mar 2019 11:20:29 +0000	[thread overview]
Message-ID: <1553772029.5713.10.camel@samsung.com> (raw)
In-Reply-To: <CAN=4vMp8ahnMv-gQx3NEZod4beGMgkkWGUG-aF6vDi-DuAHRAA@mail.gmail.com>

> By the way, any chance you could take a look at
> https://www.zsh.org/mla/workers//2019/msg00204.html or ping someone who
> might?

On Sat, 2019-03-23 at 14:09 +0100, Roman Perepelitsa wrote:
> If your [up] key is bound to up-line-or-beginning-search, like most people
> have it, try the following experiment. Type sleep 6& and hit [enter]. Then
> quickly press [up] and wait for the job to finish. Once it finishes, press
> [up] again. Oh no! History doesn’t work. You are supposed to see the
> command you’d typed before sleep 6& but you are likely still seeing sleep 6&
> .
>
> Here’s what’s going on. When jobs finish, zle .reset-prompt is called to
> re-expand and display prompt. This sets LASTWIDGET to .reset-prompt. When
> you press [up] after that, up-line-or-beginning-search will behave as if
> you’ve typed sleep 6& in your prompt and then pressed [up]. That is, it’ll
> search for the previous command in your history that starts with sleep
> 6&.
>...
> One potential fix for this issue is to change reset-prompt widget so that
> it keeps LASTWIDGET unchanged. I’ve implemented this change in
> https://github.com/romkatv/zsh/tree/gentle-reset-prompt. Diff against
> upstream:
> https://github.com/zsh-users/zsh/compare/master...romkatv:gentle-reset-prompt
> .

Don't see any problem with doing that.  I suppose we really need a
list of widgets that should have this behaviour.

Ideally, this would be encapsulated as anything that happens not
as part of a user command --- in your example, that's the code executed
at the end of the job (I think as a result of setting "resetneeded" in
trahszle()) that calls last-prompt, rather than last-prompt itself.  But
that could be more major surgery, with largely the same effect since
it's that widget that's causing the problem.  So I'm perfectly happy to
get this fixed by the present means.

If you can produce this as a single change (with appropriate use of
rebase -i or whatever) we can apply it.  A patch to the list would be
fine, since other people get to see it, but I don't mind cherry-picking
/ rebasing from your repo if it's a single squashed change somewhere.

> The same branch also adds -W option to zle widget command. This option
> instructs zle to keep LASTWIDGET unchanged. I added it because it’s a
> natural extension of what I’ve done with .reset-prompt and because it has
> solved a long-standing issue I had in my zsh config.

The functionality certainly seems useful.

It might be easier simply to make LASTWIDGET read-write.  Then you could
do

  local LASTWIDGET=$LASTWIDGET

(you only need the assignment if you expect something down below to look
at it) and no new syntax is needed.  The save/restore just uses existing
mechanisms intended for doing that with variables, which seems more
efficient, too.

pws


  reply	other threads:[~2019-03-28 11:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190323131052epcas1p4ee9c963395adaa3c2bb560e1a290f6bd@epcas1p4.samsung.com>
2019-03-23 13:09 ` Roman Perepelitsa
2019-03-28 11:20   ` Peter Stephenson [this message]
2019-04-09 18:45     ` Roman Perepelitsa
2019-04-10  8:46       ` Peter Stephenson
2019-04-10  8:51         ` Roman Perepelitsa

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=1553772029.5713.10.camel@samsung.com \
    --to=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).