From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: Undo does too much
Date: Thu, 30 Mar 2000 10:48:22 +0200 (MET DST) [thread overview]
Message-ID: <200003300848.KAA26706@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: Sven Wischnowsky's message of Mon, 7 Feb 2000 14:36:45 +0100 (MET)
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@informatik.hu-berlin.de
reply other threads:[~2000-03-30 8:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200003300848.KAA26706@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/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).