aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-02 22:50:14 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-02 22:50:14 +1200
commitc55d432ff756495c15032c22f6f8f57673569b4b (patch)
tree06de1b185db8ffde55f1c81a560209c64d501d98
parentMerge branch 'hotfix/v0.1.1' (diff)
parentBump VERSION (diff)
downloadvim-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--VERSION2
-rw-r--r--doc/insert_cancel.txt14
-rw-r--r--plugin/insert_cancel.vim15
3 files changed, 23 insertions, 8 deletions
diff --git a/VERSION b/VERSION
index 17e51c3..0ea3a94 100644
--- a/VERSION
+++ b/VERSION
@@ -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