# HG changeset patch # User Christian Brabandt # Date 1705422611 -3600 # Node ID 8687845c326c7e30eff28bca3d474731628efeb8 # Parent efe7982ac11832eecf279e396ae540abd917de06 patch 9.1.0035: i_CTRL-] triggers InsertCharPre Commit: https://github.com/vim/vim/commit/7d711fe2092d0438d2df5054df735ec34926e2bc Author: altermo <> Date: Tue Jan 16 17:25:17 2024 +0100 patch 9.1.0035: i_CTRL-] triggers InsertCharPre Problem: i_CTRL-] triggers InsertCharPre Solution: Return if CTRL-] is received. InsertCharPre is supposed to be only used for chars to be inserted but i_CTRL-] triggers expansion and is not inserted into the buffer (altermo) closes: #13853 closes: #13864 Signed-off-by: altermo Signed-off-by: Christian Brabandt diff --git a/src/edit.c b/src/edit.c --- a/src/edit.c +++ b/src/edit.c @@ -5371,6 +5371,9 @@ do_insert_char_pre(int c) if (!has_insertcharpre()) return NULL; + if (c == Ctrl_RSB) + return NULL; + if (has_mbyte) buf[(*mb_char2bytes)(c, buf)] = NUL; else diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -2123,4 +2123,39 @@ func Test_edit_shift_bs() call StopVimInTerminal(buf) endfunc +func Test_edit_Ctrl_RSB() + new + let g:triggered = [] + autocmd InsertCharPre let g:triggered += [v:char] + + " i_CTRL-] should not trigger InsertCharPre + exe "normal! A\" + call assert_equal([], g:triggered) + + " i_CTRL-] should expand abbreviations but not trigger InsertCharPre + inoreabbr f foo + exe "normal! Af\a" + call assert_equal(['f', 'f', 'o', 'o', 'a'], g:triggered) + call assert_equal('fooa', getline(1)) + + " CTRL-] followed by i_CTRL-V should not expand abbreviations + " i_CTRL-V doesn't trigger InsertCharPre + call setline(1, '') + exe "normal! Af\\" + call assert_equal("f\", getline(1)) + + let g:triggered = [] + call setline(1, '') + + " Also test assigning to v:char + autocmd InsertCharPre let v:char = 'f' + exe "normal! Ag\h" + call assert_equal(['g', 'f', 'o', 'o', 'h'], g:triggered) + call assert_equal('ffff', getline(1)) + + autocmd! InsertCharPre + unlet g:triggered + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -705,6 +705,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 35, +/**/ 34, /**/ 33,