Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Proposal (with code) to fix breaking of history widgets on reset-prompt
- X-seq: zsh-workers 44189
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: <zsh-workers@xxxxxxx>
- Subject: Re: Proposal (with code) to fix breaking of history widgets on reset-prompt
- Date: Thu, 28 Mar 2019 11:20:29 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190328112031euoutp0180148df90643da8bd4c791c5f553b314~QG25AWUag1474514745euoutp01q
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1553772031; bh=5nt9DG7kumgkvAPMX6FHQmwp34cYnalspGgOkg6EqWg=; h=Subject:From:To:Date:In-Reply-To:References:From; b=sO65RVj1vnbWcw4n3VRqFfG0E6dvtaP7LhsnMCw/sxpuWagTgdqm83fkzcJTEhYWj 56sfU5UY7a1WdHWSrbuh1b0/eT4gIZ9EHAdS5SLvCx/JZB8PM+c1cesNDk2eLn3MoF EgxJUKhJBqXyDTq//A0Ar7PaMmZErOSeaBQkaDE8=
- In-reply-to: <CAN=4vMp8ahnMv-gQx3NEZod4beGMgkkWGUG-aF6vDi-DuAHRAA@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
- References: <CGME20190323131052epcas1p4ee9c963395adaa3c2bb560e1a290f6bd@epcas1p4.samsung.com> <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author