diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Doc/Zsh/zle.yo | 16 | ||||
-rw-r--r-- | Test/X02zlevi.ztst | 57 | ||||
-rw-r--r-- | Test/comptest | 2 |
4 files changed, 76 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index b836b0e83..978adb1fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2014-02-05 Oliver Kiddle <opk@zsh.org> + * 32355: Doc/Zsh/zle.yo Test/X02zlevi.ztst Test/comptest: document + and test vi mode undo changes + * 32342: Src/Zle/zle_main.c, Src/Zle/zle_vi.c: fix overstrike for vi mode and use varying vi commands at line start diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index 2d7756859..6d3bb4bd0 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -1293,8 +1293,11 @@ item(tt(redisplay))( Redisplay the command line, remaining in incremental search mode. ) item(tt(vi-cmd-mode))( -Toggle between the `tt(main)' and `tt(vicmd)' keymaps; +Select the `tt(vicmd)' keymap; the `tt(main)' keymap (insert mode) will be selected initially. + +In addition, the modifications that were made while in vi insert mode are +merged to form a single undo event. ) xitem(tt(vi-repeat-search)) item(tt(vi-rev-repeat-search))( @@ -2191,6 +2194,13 @@ tindex(spell-word) item(tt(spell-word) (ESC-$ ESC-S ESC-s) (unbound) (unbound))( Attempt spelling correction on the current word. ) +tindex(split-undo) +item(tt(split-undo))( +Breaks the undo sequence at the current change. This is useful in vi mode as +changes made in insert mode are coalesced on entering command mode. Similarly, +tt(undo) will normally revert as one all the changes made by a user-defined +widget. +) tindex(undefined-key) item(tt(undefined-key))( This command is executed when a key sequence that is not bound to any @@ -2202,6 +2212,10 @@ Incrementally undo the last text modification. When called from a user-defined widget, takes an optional argument indicating a previous state of the undo history as returned by the tt(UNDO_CHANGE_NO) variable; modifications are undone until that state is reached. + +Note that when invoked from vi command mode, the full prior change made in +insert mode is reverted, the changes having been merged when command mode was +selected. ) tindex(redo) item(tt(redo))( diff --git a/Test/X02zlevi.ztst b/Test/X02zlevi.ztst index d4a125f21..fe55d8a26 100644 --- a/Test/X02zlevi.ztst +++ b/Test/X02zlevi.ztst @@ -10,6 +10,63 @@ %test + zletest $'word\euaend' +0:undo initial change +>BUFFER: end +>CURSOR: 3 + + zletest $'text\e.' +0:repeat initial edit +>BUFFER: text +>text +>CURSOR: 8 + + comptesteval 'print -z before' + zletest $'after\e.' +0:repeat initial edit with non-blank starting line +>BUFFER: beforeafterafter +>CURSOR: 15 + + comptesteval 'setopt overstrike;print -z bung' + zletest $'ing\e2|.' +0:repeat initial edit with overstrike set +>BUFFER: binging +>CURSOR: 3 + + comptesteval 'bindkey "^_" undo' + zletest $'undoc\037e' +0:use of undo in vi insert mode +>BUFFER: undoe +>CURSOR: 5 + + zletest $'one\euatwo\e0clthree' +0:vi mode undo of initial and subsequent change +>BUFFER: threewo +>CURSOR: 5 + + zletest $'xxx\euiyyy\euAz' +0:undo invoked twice +>BUFFER: z +>CURSOR: 1 + + comptesteval 'bindkey -a "^R" redo' + zletest $'123\C-_\e\C-r' +0:undo in insert mode, redo in command +>BUFFER: 123 +>CURSOR: 2 + + comptesteval 'bindkey "^Y" redo' + zletest $'pre\eA123\C-_\C-y\eu' +0:undo and redo in insert mode, undo in command +>BUFFER: pre +>CURSOR: 2 + + comptesteval 'bindkey "^Gu" split-undo' + zletest $'one\C-gutwo\eu' +0:split the undo sequence +>BUFFER: one +>CURSOR: 2 + zletest $'one two\ebmt3|`tx``' 0:setting mark and returning to original position >BUFFER: one wo diff --git a/Test/comptest b/Test/comptest index 10814d635..f1c5af01f 100644 --- a/Test/comptest +++ b/Test/comptest @@ -72,8 +72,8 @@ zle-finish () { print -lr "<WIDGET><finish>" "BUFFER: $BUFFER" "CURSOR: $CURSOR" (( region_active )) && print -lr "MARK: $MARK" zle -K main - zle kill-whole-line zle clear-screen + zle send-break zle -R } zle -N expand-or-complete-with-report |