zsh-workers
 help / color / mirror / code / Atom feed
From: "Jun T." <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: zle: vi mode: wrong undo handling on fresh lines
Date: Thu, 30 Jan 2014 23:51:10 +0900	[thread overview]
Message-ID: <EA3D3D1C-A0E8-4DA0-B10D-5B428A02AB51@kba.biglobe.ne.jp> (raw)
In-Reply-To: <2700.1390950035@thecus.kiddle.eu>

This is my "trial" to (somewhat) improve the behavior of 'undo' after completion.
The patch below is against (git-HEAD)+(patch in 32314 by Oliver Kiddle).

The change in zle_tricky.c is to start a new undo-block when entering a
completion.

The change in zle_main.c is to make 'undo' no to bring back the suffix added
by completion but erased when going back to the command mode.
(This will also change the behavior in emacs-mode.)

Or these are just matter of preference and must not be hard-coded but
configurable?



diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index f5aec84..72650a8 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1332,8 +1332,10 @@ execzlefunc(Thingy func, char **args, int set_bindk)
 	    eofsent = 1;
 	    ret = 1;
 	} else {
-	    if(!(wflags & ZLE_KEEPSUFFIX))
+	    if(!(wflags & ZLE_KEEPSUFFIX)) {
 		removesuffix();
+		handleundo();
+	    }
 	    if(!(wflags & ZLE_MENUCMP)) {
 		fixsuffix();
 		invalidatelist();
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 2689d0f..49dae8a 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -673,6 +673,9 @@ docomplete(int lst)
      * an emulation.                                                      */
     if (viinsbegin > ztrsub(zlemetaline + wb, zlemetaline))
 	viinsbegin = ztrsub(zlemetaline + wb, zlemetaline);
+    /* finish the current undo block and start a new one */
+    vimergeundo();
+    vistartchange = (curchange && curchange->prev) ? curchange->prev->changeno : 0;
     /* If we added chline to the line buffer, reset the original contents. */
     if (ol) {
 	zlemetacs -= chl;
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 9e9cc2f..e6c10a1 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -112,6 +112,19 @@ startvitext(int im)
 }
 
 /**/
+void
+vimergeundo(void)
+{
+    struct change *current = curchange->prev;
+    while (current && current->changeno > vistartchange+1) {
+	current->flags |= CH_PREV;
+	current = current->prev;
+	if (!current) break;
+	current->flags |= CH_NEXT;
+    }
+}
+
+/**/
 ZLE_INT_T
 vigetkey(void)
 {
@@ -584,13 +597,7 @@ vicmdmode(UNUSED(char **args))
 {
     if (invicmdmode() || selectkeymap("vicmd", 0))
 	return 1;
-    struct change *current = curchange->prev;
-    while (current && current->changeno > vistartchange+1) {
-	current->flags |= CH_PREV;
-	current = current->prev;
-	if (!current) break;
-	current->flags |= CH_NEXT;
-    }
+    vimergeundo();
     vichgflag = 0;
     if (zlecs != findbol())
 	DECCS();



  parent reply	other threads:[~2014-01-30 15:26 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-22 12:37 Hauke Petersen
2013-09-22 18:24 ` Bart Schaefer
2013-09-22 20:27   ` Hauke Petersen
2013-09-23  4:57     ` Bart Schaefer
2013-09-23 20:30 ` Peter Stephenson
2014-01-24 23:19   ` Oliver Kiddle
2014-01-25 19:15     ` Bart Schaefer
2014-01-27 12:43       ` Peter Stephenson
2014-01-27 16:11         ` Peter Stephenson
2014-01-28 14:58           ` Peter Stephenson
2014-01-28 16:28             ` Bart Schaefer
2014-01-28 16:47               ` Peter Stephenson
2014-01-28 17:41                 ` Bart Schaefer
2014-01-28 23:00           ` Oliver Kiddle
2014-01-29  2:59             ` Bart Schaefer
2014-01-29 10:50               ` Oliver Kiddle
2014-01-29 14:48                 ` Bart Schaefer
2014-01-30 14:51             ` Jun T. [this message]
2014-01-30 15:38               ` Peter Stephenson
2014-01-30 16:03                 ` Bart Schaefer
2014-01-31 12:00               ` Jun T.
2014-01-31 15:19                 ` Bart Schaefer
2014-01-31 15:33                   ` Peter Stephenson
     [not found]               ` <16181.1391175951@thecus.kiddle.eu>
2014-01-31 16:43                 ` Jun T.
2014-01-31 21:37               ` Oliver Kiddle
2014-01-31 22:32                 ` Oliver Kiddle
2014-02-01 19:27                   ` Bart Schaefer
2014-02-03 16:20                   ` Jun T.
2014-02-03 21:29                     ` Oliver Kiddle
2014-02-03 22:20                       ` Bart Schaefer
2014-02-03 23:26                         ` Oliver Kiddle
2014-02-04 17:11                           ` Jun T.
2014-02-05 22:00                             ` Oliver Kiddle
2014-02-02 22:10             ` Oliver Kiddle
2014-02-07 14:43             ` Oliver Kiddle
2014-02-07 16:22               ` Bart Schaefer
2014-01-27 16:29         ` Bart Schaefer

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=EA3D3D1C-A0E8-4DA0-B10D-5B428A02AB51@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --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).