diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-02 22:50:14 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-07-02 22:50:14 +1200 |
commit | c55d432ff756495c15032c22f6f8f57673569b4b (patch) | |
tree | 06de1b185db8ffde55f1c81a560209c64d501d98 | |
parent | Merge branch 'hotfix/v0.1.1' (diff) | |
parent | Bump VERSION (diff) | |
download | vim-insert-cancel-c55d432ff756495c15032c22f6f8f57673569b4b.tar.gz vim-insert-cancel-c55d432ff756495c15032c22f6f8f57673569b4b.zip |
Merge branch 'release/v0.2.0'v0.2.0
* release/v0.2.0:
Bump VERSION
Check '[ and '] marks as well for insert
Correct a version number comparison
Add a BUGS section
Use a correct doc reference
Use b:changedtick instead of changenr()
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | doc/insert_cancel.txt | 14 | ||||
-rw-r--r-- | plugin/insert_cancel.vim | 15 |
3 files changed, 23 insertions, 8 deletions
@@ -1 +1 @@ -0.1.1 +0.2.0 diff --git a/doc/insert_cancel.txt b/doc/insert_cancel.txt index df3205f..c62671e 100644 --- a/doc/insert_cancel.txt +++ b/doc/insert_cancel.txt @@ -9,8 +9,8 @@ operation. REQUIREMENTS *insert_cancel-requirements* This plugin is only available if 'compatible' is not set. It works best if -|+autocmd| is available, with the |InsertLeave| event from |version7|. It does -a much better job of telling whether a change was made with these features +|+autocmd| is available, with the |InsertLeave| event from |vim7|. It does a +much better job of telling whether a change was made with these features available, which avoids undoing unrelated changes inappropriately. MAPPINGS *insert_cancel-mappings* @@ -22,6 +22,16 @@ yourself in your |vimrc|. For example: > imap <C-C> <Plug>InsertCancel < +BUGS *insert_cancel-bugs* + +If you open a line with |o| or |O|, and then press |i_CTRL-C| without making +any other changes, that change will not be reverted. + +This is because for |o| and |O|, |b:changedticks| is incremented before the +|InsertLeave| event used to sample the counter for comparison with when CTRL-C +is pressed, and I can't figure out how to catch it any earlier without using +|CursorMoved| or or |vim8|'s |TextChanged|, which I'd rather avoid. + AUTHOR *insert_cancel-author* Written and maintained by Tom Ryder <tom@sanctum.geek.nz>. diff --git a/plugin/insert_cancel.vim b/plugin/insert_cancel.vim index 636a54e..33735ae 100644 --- a/plugin/insert_cancel.vim +++ b/plugin/insert_cancel.vim @@ -14,21 +14,26 @@ if v:version < 600 endif let g:loaded_insert_cancel = 1 -" Initialise s:changenr so vint understands -let s:changenr = 0 +" Initialise s:changedtick so vint understands +let s:changedtick = 0 " InsertEnter is only available from Vim 7 -if has('autocmd') && v:version > 700 +if has('autocmd') && v:version >= 700 augroup insert_cancel autocmd! autocmd InsertEnter * - \ let s:changenr = changenr() + \ let s:changedtick = b:changedtick augroup END endif " Try to figure out whether we made a change to undo, undo it if so function! s:InsertCancel() - if &modified && (!exists('*changenr') || changenr() > s:changenr) + if !&modified + return + endif + if s:changedtick > 0 && b:changedtick > s:changedtick + \ || line("'[") != line("']") + \ || col("'[") != col("']") silent undo endif endfunction |