diff options
Diffstat (limited to 'Src/Zle')
-rw-r--r-- | Src/Zle/zle_keymap.c | 2 | ||||
-rw-r--r-- | Src/Zle/zle_move.c | 33 | ||||
-rw-r--r-- | Src/Zle/zle_tricky.c | 15 | ||||
-rw-r--r-- | Src/Zle/zle_utils.c | 38 |
4 files changed, 64 insertions, 24 deletions
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index c3731c47b..e21e769bd 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -912,7 +912,7 @@ bin_bindkey_new(char *name, UNUSED(char *kmname), Keymap km, char **argv, UNUSED if(argv[1]) { km = openkeymap(argv[1]); if(!km) { - zwarnnam(name, "no such keymap `%s'", argv[0]); + zwarnnam(name, "no such keymap `%s'", argv[1]); return 1; } } else diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c index 0e940bc21..d5f464c2c 100644 --- a/Src/Zle/zle_move.c +++ b/Src/Zle/zle_move.c @@ -679,7 +679,7 @@ vifindnextchar(char **args) if ((vfindchar = vigetkey()) != ZLEEOF) { vfinddir = 1; tailadd = 0; - return virepeatfind(args); + return vifindchar(0, args); } return 1; } @@ -691,7 +691,7 @@ vifindprevchar(char **args) if ((vfindchar = vigetkey()) != ZLEEOF) { vfinddir = -1; tailadd = 0; - return virepeatfind(args); + return vifindchar(0, args); } return 1; } @@ -703,7 +703,7 @@ vifindnextcharskip(char **args) if ((vfindchar = vigetkey()) != ZLEEOF) { vfinddir = 1; tailadd = -1; - return virepeatfind(args); + return vifindchar(0, args); } return 1; } @@ -715,14 +715,14 @@ vifindprevcharskip(char **args) if ((vfindchar = vigetkey()) != ZLEEOF) { vfinddir = -1; tailadd = 1; - return virepeatfind(args); + return vifindchar(0, args); } return 1; } /**/ int -virepeatfind(char **args) +vifindchar(int repeat, char **args) { int ocs = zlecs, n = zmult; @@ -735,6 +735,16 @@ virepeatfind(char **args) zmult = n; return ret; } + if (repeat && tailadd != 0) { + if (vfinddir > 0) { + if(zlecs < zlell && (ZLE_INT_T)zleline[zlecs+1] == vfindchar) + INCCS(); + } + else { + if(zlecs > 0 && (ZLE_INT_T)zleline[zlecs-1] == vfindchar) + DECCS(); + } + } while (n--) { do { if (vfinddir > 0) @@ -760,19 +770,28 @@ virepeatfind(char **args) /**/ int +virepeatfind(char **args) +{ + return vifindchar(1, args); +} + +/**/ +int virevrepeatfind(char **args) { int ret; if (zmult < 0) { zmult = -zmult; - ret = virepeatfind(args); + ret = vifindchar(1, args); zmult = -zmult; return ret; } + tailadd = -tailadd; vfinddir = -vfinddir; - ret = virepeatfind(args); + ret = vifindchar(1, args); vfinddir = -vfinddir; + tailadd = -tailadd; return ret; } diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 6fa887a1e..78a9fa490 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -1071,7 +1071,8 @@ has_real_token(const char *s) static char * get_comp_string(void) { - int t0, tt0, i, j, k, cp, rd, sl, ocs, ins, oins, ia, parct, varq = 0; + enum lextok t0, tt0; + int i, j, k, cp, rd, sl, ocs, ins, oins, ia, parct, varq = 0; int ona = noaliases; /* * Index of word being considered @@ -1152,7 +1153,8 @@ get_comp_string(void) lexflags = LEXFLAGS_ZLE; inpush(dupstrspace(linptr), 0, NULL); strinbeg(0); - wordpos = tt0 = cp = rd = ins = oins = linarr = parct = ia = redirpos = 0; + wordpos = cp = rd = ins = oins = linarr = parct = ia = redirpos = 0; + tt0 = NULLTOK; /* This loop is possibly the wrong way to do this. It goes through * * the previously massaged command line using the lexer. It stores * @@ -1238,7 +1240,8 @@ get_comp_string(void) if (tt) break; /* Otherwise reset the variables we are collecting data in. */ - wordpos = tt0 = cp = rd = ins = redirpos = 0; + wordpos = cp = rd = ins = redirpos = 0; + tt0 = NULLTOK; } if (lincmd && (tok == STRING || tok == FOR || tok == FOREACH || tok == SELECT || tok == REPEAT || tok == CASE)) { @@ -1251,7 +1254,7 @@ get_comp_string(void) if (wordpos != redirpos) wordpos = redirpos = 0; } - if (!lexflags && !tt0) { + if (!lexflags && tt0 == NULLTOK) { /* This is done when the lexer reached the word the cursor is on. */ tt = tokstr ? dupstring(tokstr) : NULL; @@ -1352,7 +1355,7 @@ get_comp_string(void) (sl - 1) : (zlemetacs_qsub - wb)]); } } while (tok != LEXERR && tok != ENDINPUT && - (tok != SEPER || (lexflags && !tt0))); + (tok != SEPER || (lexflags && tt0 == NULLTOK))); /* Calculate the number of words stored in the clwords array. */ clwnum = (tt || !wordpos) ? wordpos : wordpos - 1; zsfree(clwords[clwnum]); @@ -1388,7 +1391,7 @@ get_comp_string(void) if (inwhat == IN_MATH) s = NULL; - else if (!t0 || t0 == ENDINPUT) { + else if (t0 == NULLTOK || t0 == ENDINPUT) { /* There was no word (empty line). */ s = ztrdup(""); we = wb = zlemetacs; diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index cf6787f3a..d0e7b5542 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -1363,6 +1363,10 @@ static struct change *nextchanges, *endnextchanges; static zlong undo_changeno; +/* If non-zero, the last increment to undo_changeno was for the variable */ + +static int undo_set_by_variable; + /**/ void initundo(void) @@ -1373,6 +1377,7 @@ initundo(void) curchange->del = curchange->ins = NULL; curchange->dell = curchange->insl = 0; curchange->changeno = undo_changeno = 0; + undo_set_by_variable = 0; lastline = zalloc((lastlinesz = linesz) * ZLE_CHAR_SIZE); ZS_memcpy(lastline, zleline, (lastll = zlell)); lastcs = zlecs; @@ -1498,6 +1503,7 @@ mkundoent(void) ch->prev = NULL; } ch->changeno = ++undo_changeno; + undo_set_by_variable = 0; endnextchanges = ch; } @@ -1520,23 +1526,25 @@ setlastline(void) int undo(char **args) { - zlong last_change = (zlong)0; + zlong last_change; if (*args) - { last_change = zstrtol(*args, NULL, 0); - } + else + last_change = (zlong)-1; handleundo(); do { - if(!curchange->prev) + struct change *prev = curchange->prev; + if(!prev) return 1; - if (unapplychange(curchange->prev)) - curchange = curchange->prev; + if (prev->changeno < last_change) + break; + if (unapplychange(prev)) + curchange = prev; else break; - } while (*args ? curchange->changeno != last_change : - (curchange->flags & CH_PREV)); + } while (last_change >= (zlong)0 || (curchange->flags & CH_PREV)); setlastline(); return 0; } @@ -1660,6 +1668,16 @@ zlecallhook(char *name, char *arg) zlong get_undo_current_change(UNUSED(Param pm)) { - return undo_changeno; + if (undo_set_by_variable) { + /* We were the last to increment this, doesn't need another one. */ + return undo_changeno; + } + undo_set_by_variable = 1; + /* + * Increment the number in case a change is in progress; + * we don't want to back off what's already been done when + * we return to this change number. This eliminates any + * problem about the point where a change is numbered. + */ + return ++undo_changeno; } - |