Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zle: vi mode: wrong undo handling on fresh lines
Unconditionally calling vimergeundo() from docomplete() makes the
behavior of 'undo' in emacs mode. For example,
$ ls f<tab>
$ ls foo # assume there is a file 'foo'
$ ls foo<undo>
$ ls f<undo>
now <undo> 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 = flags;
zlecontext = context;
histline = curhist;
- vistartchange = 0;
+ vistartchange = -1;
zleline = (ZLE_STRING_T)zalloc(((linesz = 256) + 2) * ZLE_CHAR_SIZE);
*zleline = ZWC('\0');
virangeflag = lastcmd = done = zlecs = zlell = mark = 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 = ztrsub(zlemetaline + wb, zlemetaline);
/* finish the current undo block and start a new one */
- vimergeundo();
- vistartchange = (curchange && curchange->prev) ? curchange->prev->changeno : 0;
+ if (vistartchange >= 0) {
+ 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 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 = curchange->prev;
+ if (vistartchange < 0)
+ return;
while (current && current->changeno > vistartchange+1) {
current->flags |= CH_PREV;
current = current->prev;
Messages sorted by:
Reverse Date,
Date,
Thread,
Author