diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-10-21 23:25:21 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-10-21 23:36:56 -0400 |
commit | 3f0850e9f053db6e1e5b4911c975c13f4a1624b0 (patch) | |
tree | 650af6c16bfe613c8f55111b92195bae6e60497a | |
parent | 07022306e211ab57ddf97220b28ef875f2a3a9fe (diff) | |
download | rneovim-3f0850e9f053db6e1e5b4911c975c13f4a1624b0.tar.gz rneovim-3f0850e9f053db6e1e5b4911c975c13f4a1624b0.tar.bz2 rneovim-3f0850e9f053db6e1e5b4911c975c13f4a1624b0.zip |
vim-patch:8.2.1874: can't do something just before leaving Insert mode
Problem: Can't do something just before leaving Insert mode.
Solution: Add the InsertLeavePre autocommand event. (closes vim/vim#7177)
https://github.com/vim/vim/commit/b53e13a91ab2fc9d52bd044715daa84972f4ce47
N/A patches for version.c:
vim-patch:8.1.1877: graduated features scattered
Problem: Graduated features scattered.
Solution: Put graduated and obsolete features together.
https://github.com/vim/vim/commit/ffc0716af8e448ef8a2a3249edfd0260546933df
vim-patch:8.2.1875: warning when building GTK gui
Problem: Warning when building GTK gui.
Solution: Add missing function parameter.
https://github.com/vim/vim/commit/3da855c8e28140d9f02b1572e445f8d4f977cf64
vim-patch:8.2.1877: test for function list fails
Problem: Test for function list fails.
Solution: Move "obsolete" comments one line up.
https://github.com/vim/vim/commit/b8f519e5382f9876ae7f8bc64d9814d07a8ef972
vim-patch:8.2.1878: GTK: error for redefining function
Problem: GTK: error for redefining function. (Tony Mechelynck)
Solution: Remove "gtk_" prefix from local functions and prepend "gui_" to
global functions.
https://github.com/vim/vim/commit/8a99e66b4f7616d9b0b9cefe742f82f9122087d5
vim-patch:8.2.1881: cannot build with GTK3
Problem: Cannot build with GTK3.
Solution: Adjust form functions.
https://github.com/vim/vim/commit/692d1a51e74fea2db3c7e9ae7c7c6c3a1a1945ee
vim-patch:8.2.1883: compiler warnings when using Python
Problem: Compiler warnings when using Python.
Solution: Adjust PyCFunction to also have the second argument. Use "int"
return type for some functions. Insert "(void *)" to get rid of
the remaining warnings.
https://github.com/vim/vim/commit/4ce5fe4c87820c7d22964d6e91d7b07e96640e6f
-rw-r--r-- | runtime/doc/autocmd.txt | 9 | ||||
-rw-r--r-- | src/nvim/auevents.lua | 3 | ||||
-rw-r--r-- | src/nvim/edit.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_edit.vim | 11 |
4 files changed, 23 insertions, 4 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index a6872d0af5..a728593c40 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -700,9 +700,14 @@ InsertEnter Just before starting Insert mode. Also for The cursor is restored afterwards. If you do not want that set |v:char| to a non-empty string. + *InsertLeavePre* +InsertLeavePre Just before leaving Insert mode. Also when + using CTRL-O |i_CTRL-O|. Be caseful not to + change mode or use `:normal`, it will likely + cause trouble. *InsertLeave* -InsertLeave When leaving Insert mode. Also when using - CTRL-O |i_CTRL-O|. But not for |i_CTRL-C|. +InsertLeave Just after leaving Insert mode. Also when + using CTRL-O |i_CTRL-O|. But not for |i_CTRL-C|. *MenuPopup* MenuPopup Just before showing the popup menu (under the right mouse button). Useful for adjusting the diff --git a/src/nvim/auevents.lua b/src/nvim/auevents.lua index 4391d997a7..10647c01a4 100644 --- a/src/nvim/auevents.lua +++ b/src/nvim/auevents.lua @@ -65,7 +65,8 @@ return { 'InsertChange', -- when changing Insert/Replace mode 'InsertCharPre', -- before inserting a char 'InsertEnter', -- when entering Insert mode - 'InsertLeave', -- when leaving Insert mode + 'InsertLeave', -- just after leaving Insert mode + 'InsertLeavePre', -- just before leaving Insert mode 'MenuPopup', -- just before popup menu is displayed 'OptionSet', -- after setting any option 'QuickFixCmdPost', -- after :make, :grep etc. diff --git a/src/nvim/edit.c b/src/nvim/edit.c index de2346a9d8..a917e94342 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -7691,6 +7691,10 @@ static bool ins_esc(long *count, int cmdchar, bool nomove) undisplay_dollar(); } + if (cmdchar != 'r' && cmdchar != 'v') { + ins_apply_autocmds(EVENT_INSERTLEAVEPRE); + } + // When an autoindent was removed, curswant stays after the // indent if (restart_edit == NUL && (colnr_T)temp == curwin->w_cursor.col) { diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim index caebc341e0..15c718b243 100644 --- a/src/nvim/testdir/test_edit.vim +++ b/src/nvim/testdir/test_edit.vim @@ -1441,31 +1441,40 @@ endfunc func Test_edit_InsertLeave() new + au InsertLeavePre * let g:did_au_pre = 1 au InsertLeave * let g:did_au = 1 + let g:did_au_pre = 0 let g:did_au = 0 call feedkeys("afoo\<Esc>", 'tx') + call assert_equal(1, g:did_au_pre) call assert_equal(1, g:did_au) call assert_equal('foo', getline(1)) + let g:did_au_pre = 0 let g:did_au = 0 call feedkeys("Sbar\<C-C>", 'tx') + call assert_equal(1, g:did_au_pre) call assert_equal(0, g:did_au) call assert_equal('bar', getline(1)) inoremap x xx<Esc> + let g:did_au_pre = 0 let g:did_au = 0 call feedkeys("Saax", 'tx') + call assert_equal(1, g:did_au_pre) call assert_equal(1, g:did_au) call assert_equal('aaxx', getline(1)) inoremap x xx<C-C> + let g:did_au_pre = 0 let g:did_au = 0 call feedkeys("Sbbx", 'tx') + call assert_equal(1, g:did_au_pre) call assert_equal(0, g:did_au) call assert_equal('bbxx', getline(1)) bwipe! - au! InsertLeave + au! InsertLeave InsertLeavePre iunmap x endfunc |