Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: Undo does too much
- X-seq: zsh-workers 10328
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: Re: Undo does too much
- Date: Thu, 30 Mar 2000 10:48:22 +0200 (MET DST)
- In-reply-to: Sven Wischnowsky's message of Mon, 7 Feb 2000 14:36:45 +0100 (MET)
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
I felt a bit adventurous yesterday...
Ages ago, I wrote:
> Bart Schaefer wrote:
>
> > 3.1.6-dev-17, zsh -f:
> >
> > zagzig% setopt completeinword
> > zagzig% setopt | less
> > (output elided)
> > zagzig% setopt co<ESC-p>
> > zagzig% setopt | less<CTRL-/>
> > zagzig% setopt c
> >
> > Hey, where did the 'o' go? We undid two changes, not one. (The setopts
> > are irrelevant, they're just sample input.)
The problem was that the history line stuff was handled in
unapplychange() and even if it had to get another history line, it
still unapplied the change.
> Just adding some fuel: there is also still the problem that the first
> undo after a completion with an automatically inserted suffix doesn't
> seem to have an effect (in reality, it has: auto-removing the suffix
> and undoing it back in). I once tried to fix that but failed
> completely because of the rather difficult undo-recording logic.
This seems to be fixed with the change in iwidgets.list. I know I
tried to understand how to fix this more than once... weird that I
never tried this solution.
Bye
Sven
diff -ru ../z.old/Src/Zle/iwidgets.list Src/Zle/iwidgets.list
--- ../z.old/Src/Zle/iwidgets.list Thu Mar 30 10:46:47 2000
+++ Src/Zle/iwidgets.list Thu Mar 30 10:47:10 2000
@@ -85,7 +85,7 @@
"quote-line", quoteline, 0
"quote-region", quoteregion, 0
"redisplay", redisplay, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
-"redo", redo, 0
+"redo", redo, ZLE_KEEPSUFFIX
"reverse-menu-complete", reversemenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_ISCOMP
"run-help", processcmd, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
"self-insert", selfinsert, ZLE_MENUCMP | ZLE_KEEPSUFFIX
@@ -97,7 +97,7 @@
"transpose-chars", transposechars, 0
"transpose-words", transposewords, 0
"undefined-key", undefinedkey, 0
-"undo", undo, 0
+"undo", undo, ZLE_KEEPSUFFIX
"universal-argument", universalargument, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND
"up-case-word", upcaseword, 0
"up-history", uphistory, 0
@@ -162,7 +162,7 @@
"vi-set-mark", visetmark, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL
"vi-substitute", visubstitute, 0
"vi-swap-case", viswapcase, 0
-"vi-undo-change", viundochange, 0
+"vi-undo-change", viundochange, ZLE_KEEPSUFFIX
"vi-unindent", viunindent, 0
"vi-up-line-or-history", viuplineorhistory, ZLE_LINEMOVE
"vi-yank", viyank, 0
diff -ru ../z.old/Src/Zle/zle_utils.c Src/Zle/zle_utils.c
--- ../z.old/Src/Zle/zle_utils.c Thu Mar 30 09:58:21 2000
+++ Src/Zle/zle_utils.c Thu Mar 30 10:42:40 2000
@@ -557,18 +557,24 @@
do {
if(!curchange->prev)
return 1;
- unapplychange(curchange = curchange->prev);
+ if (unapplychange(curchange->prev))
+ curchange = curchange->prev;
+ else
+ break;
} while(curchange->flags & CH_PREV);
setlastline();
return 0;
}
/**/
-static void
+static int
unapplychange(struct change *ch)
{
- if(ch->hist != histline)
+ if(ch->hist != histline) {
zle_setline(quietgethist(ch->hist));
+ cs = ch->new_cs;
+ return 0;
+ }
cs = ch->off;
if(ch->ins)
foredel(ztrlen(ch->ins));
@@ -583,6 +589,7 @@
line[cs++] = STOUC(*c);
}
cs = ch->old_cs;
+ return 1;
}
/* move forwards through the change list */
@@ -595,19 +602,24 @@
do {
if(!curchange->next)
return 1;
- applychange(curchange);
- curchange = curchange->next;
+ if (applychange(curchange))
+ curchange = curchange->next;
+ else
+ break;
} while(curchange->prev->flags & CH_NEXT);
setlastline();
return 0;
}
/**/
-static void
+static int
applychange(struct change *ch)
{
- if(ch->hist != histline)
+ if(ch->hist != histline) {
zle_setline(quietgethist(ch->hist));
+ cs = ch->old_cs;
+ return 0;
+ }
cs = ch->off;
if(ch->del)
foredel(ztrlen(ch->del));
@@ -622,6 +634,7 @@
line[cs++] = STOUC(*c);
}
cs = ch->new_cs;
+ return 1;
}
/* vi undo: toggle between the end of the undo list and the preceding point */
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author