diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2015-08-22 01:55:58 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2015-08-22 01:55:58 +0200 |
commit | 02f6e25bfcd5feb9a093377dda0dd549cdf5c309 (patch) | |
tree | 9a25e61122b3fa0d0a1ff68b5ef05c775ff78b1e /Src/Zle/zle_utils.c | |
parent | e04a19735ffc8523b93b33074f685ad4e2c92e0c (diff) | |
parent | 881474edcb223ac22a08d81a824809c33ca3a9c9 (diff) | |
download | zsh-02f6e25bfcd5feb9a093377dda0dd549cdf5c309.tar.gz zsh-02f6e25bfcd5feb9a093377dda0dd549cdf5c309.zip |
Merge tag 'zsh-5.0.8-test-2' into debian
Diffstat (limited to 'Src/Zle/zle_utils.c')
-rw-r--r-- | Src/Zle/zle_utils.c | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index e4ab97a54..d1d320613 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -1288,7 +1288,7 @@ showmsg(char const *msg) p = unmetafy(umsg, &ulen); memset(&mbs, 0, sizeof mbs); - mb_metacharinit(); + mb_charinit(); while (ulen > 0) { char const *n; if (*p == '\n') { @@ -1405,9 +1405,9 @@ static struct change *nextchanges, *endnextchanges; /**/ zlong undo_changeno; -/* If non-zero, the last increment to undo_changeno was for the variable */ +/* If positive, don't undo beyond this point */ -static int undo_set_by_variable; +zlong undo_limitno; /**/ void @@ -1418,8 +1418,7 @@ initundo(void) curchange->prev = curchange->next = NULL; curchange->del = curchange->ins = NULL; curchange->dell = curchange->insl = 0; - curchange->changeno = undo_changeno = 0; - undo_set_by_variable = 0; + curchange->changeno = undo_changeno = undo_limitno = 0; lastline = zalloc((lastlinesz = linesz) * ZLE_CHAR_SIZE); ZS_memcpy(lastline, zleline, (lastll = zlell)); lastcs = zlecs; @@ -1545,7 +1544,6 @@ mkundoent(void) ch->prev = NULL; } ch->changeno = ++undo_changeno; - undo_set_by_variable = 0; endnextchanges = ch; } @@ -1580,12 +1578,13 @@ undo(char **args) struct change *prev = curchange->prev; if(!prev) return 1; - if (prev->changeno < last_change) - break; - if (unapplychange(prev)) - curchange = prev; - else + if (prev->changeno <= last_change) break; + if (prev->changeno <= undo_limitno && !*args) + return 1; + if (!unapplychange(prev) && last_change >= 0) + unapplychange(prev); + curchange = prev; } while (last_change >= (zlong)0 || (curchange->flags & CH_PREV)); setlastline(); return 0; @@ -1735,16 +1734,22 @@ zlecallhook(char *name, char *arg) zlong get_undo_current_change(UNUSED(Param pm)) { - 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; + /* add entry for any pending changes */ + mkundoent(); + setlastline(); + return undo_changeno; +} + +/**/ +zlong +get_undo_limit_change(UNUSED(Param pm)) +{ + return undo_limitno; +} + +/**/ +void +set_undo_limit_change(UNUSED(Param pm), zlong value) +{ + undo_limitno = value; } |