From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17386 invoked by alias); 4 Feb 2014 17:11:57 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 32349 Received: (qmail 7309 invoked from network); 4 Feb 2014 17:11:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-Biglobe-Sender: Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Subject: Re: zle: vi mode: wrong undo handling on fresh lines From: "Jun T." In-Reply-To: <17235.1391469962@thecus.kiddle.eu> Date: Wed, 5 Feb 2014 02:11:44 +0900 Content-Transfer-Encoding: 7bit Message-Id: <0DF7F868-2406-473B-9477-D9FA5F6109F5@kba.biglobe.ne.jp> References: <20130923213014.15f97f9e@pws-pc.ntlworld.com> <3511.1390605547@thecus.kiddle.eu> <140125111530.ZM21792@torch.brasslantern.com> <20140127124301.4144f2d9@pwslap01u.europe.root.pri> <20140127161124.2aa16b37@pwslap01u.europe.root.pri> <2700.1390950035@thecus.kiddle.eu> <19068.1391204240@thecus.kiddle.eu> <19751.1391207572@thecus.kiddle.eu> <163F74F2-3FA8-4478-B354-491C006590C9@kba.biglobe.ne.jp> <16516.1391462981@thecus.kiddle.eu> <17235.1391469962@thecus.kiddle.eu> To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.1827) 2014/02/04 08:26, Oliver Kiddle wrote: > Anyway with the help of your hint, perhaps this: > zle -C undo-complete-word .complete-word _main_complete > complete-word() { > zle split-undo > zle undo-complete-word > } > zle -N complete-word Thanks. It seems this solves my second problem. There is another problem, however: $ bindkey -v $ echo xxxu # type something and then undo $ # this is OK $ echo yyy # hit 'i' and type something more $ echo yyyu # undo again $ # also OK, but if I hit 'u' again $ echo yyy # then the command line goes back to this Of course the expected behavior is that the command line remains empty because there is nothing more to undo. A possible patch is attached below. What the patch does is to set CH_PREV in current->flags only if current->prev exists. # If CH_PREV is set when current->prev is NULL, undo() returns # without calling setlastline() (zle_utils.c, line 1543). # This means lastline remains as "echo yyy" even if zleline is # erased to "", and next call of handleundo() will add a wrong # undo entry. diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index 68d27f8..3af8ed7 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -1649,12 +1649,12 @@ splitundo(char **args) void mergeundo(void) { - struct change *current = curchange->prev; - while (current && current->changeno > vistartchange+1) { + struct change *current; + for (current = curchange->prev; + current && current->prev && current->changeno > vistartchange+1; + current = current->prev) { current->flags |= CH_PREV; - current = current->prev; - if (!current) break; - current->flags |= CH_NEXT; + current->prev->flags |= CH_NEXT; } }