From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20423 invoked by alias); 31 Jan 2014 12:00:07 -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: 32330 Received: (qmail 9519 invoked from network); 31 Jan 2014 11:59:59 -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: Date: Fri, 31 Jan 2014 21:00:02 +0900 Content-Transfer-Encoding: quoted-printable Message-Id: <56F5B279-C8C6-47D1-9E20-457E2443ADD8@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> To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.1827) Unconditionally calling vimergeundo() from docomplete() makes the behavior of 'undo' in emacs mode. For example, $ ls f $ ls foo # assume there is a file 'foo' $ ls foo $ ls f now will remove the entire command line (the original behavior is to remove only 'f'). If this is a problem, then consider the following patch (this patch assume my patch in 32324 has been already applied): diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 72650a8..316115a 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1189,7 +1189,7 @@ zleread(char **lp, char **rp, int flags, int = context, char *init, char *finish) zlereadflags =3D flags; zlecontext =3D context; histline =3D curhist; - vistartchange =3D 0; + vistartchange =3D -1; zleline =3D (ZLE_STRING_T)zalloc(((linesz =3D 256) + 2) * = ZLE_CHAR_SIZE); *zleline =3D ZWC('\0'); virangeflag =3D lastcmd =3D done =3D zlecs =3D zlell =3D mark =3D = 0; diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 49dae8a..99cdb8f 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -674,8 +674,11 @@ docomplete(int lst) if (viinsbegin > ztrsub(zlemetaline + wb, zlemetaline)) viinsbegin =3D ztrsub(zlemetaline + wb, zlemetaline); /* finish the current undo block and start a new one */ - vimergeundo(); - vistartchange =3D (curchange && curchange->prev) ? = curchange->prev->changeno : 0; + if (vistartchange >=3D 0) { + vimergeundo(); + vistartchange =3D (curchange && curchange->prev) ? + curchange->prev->changeno : 0; + } /* If we added chline to the line buffer, reset the original = contents. */ if (ol) { zlemetacs -=3D chl; diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index e6c10a1..64bdbd8 100644 --- a/Src/Zle/zle_vi.c +++ b/Src/Zle/zle_vi.c @@ -116,6 +116,8 @@ void vimergeundo(void) { struct change *current =3D curchange->prev; + if (vistartchange < 0) + return; while (current && current->changeno > vistartchange+1) { current->flags |=3D CH_PREV; current =3D current->prev;