To: vim_dev@googlegroups.com Subject: Patch 8.1.0504 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0504 Problem: When CTRL-C is mapped it triggers InsertLeave. Solution: Make CTRL-C behave the same way when typed or used in a mapping. Files: src/edit.c, src/testdir/test_edit.vim *** ../vim-8.1.0503/src/edit.c 2018-09-30 21:43:17.179693404 +0200 --- src/edit.c 2018-11-02 11:58:53.235548305 +0100 *************** *** 1048,1054 **** if (ins_esc(&count, cmdchar, nomove)) { ! if (cmdchar != 'r' && cmdchar != 'v') ins_apply_autocmds(EVENT_INSERTLEAVE); did_cursorhold = FALSE; return (c == Ctrl_O); --- 1048,1057 ---- if (ins_esc(&count, cmdchar, nomove)) { ! // When CTRL-C was typed got_int will be set, with the result ! // that the autocommands won't be executed. When mapped got_int ! // is not set, but let's keep the behavior the same. ! if (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C) ins_apply_autocmds(EVENT_INSERTLEAVE); did_cursorhold = FALSE; return (c == Ctrl_O); *************** *** 2408,2414 **** int vim_is_ctrl_x_key(int c) { ! /* Always allow ^R - let it's results then be checked */ if (c == Ctrl_R) return TRUE; --- 2411,2417 ---- int vim_is_ctrl_x_key(int c) { ! // Always allow ^R - let its results then be checked if (c == Ctrl_R) return TRUE; *** ../vim-8.1.0503/src/testdir/test_edit.vim 2018-07-28 17:07:48.608154066 +0200 --- src/testdir/test_edit.vim 2018-11-02 11:50:34.466489066 +0100 *************** *** 1409,1411 **** --- 1409,1441 ---- bwipe XAltFile call delete('XAltFile') endfunc + + func Test_leave_insert_autocmd() + new + au InsertLeave * let g:did_au = 1 + let g:did_au = 0 + call feedkeys("afoo\", 'tx') + call assert_equal(1, g:did_au) + call assert_equal('foo', getline(1)) + + let g:did_au = 0 + call feedkeys("Sbar\", 'tx') + call assert_equal(0, g:did_au) + call assert_equal('bar', getline(1)) + + inoremap x xx + let g:did_au = 0 + call feedkeys("Saax", 'tx') + call assert_equal(1, g:did_au) + call assert_equal('aaxx', getline(1)) + + inoremap x xx + let g:did_au = 0 + call feedkeys("Sbbx", 'tx') + call assert_equal(0, g:did_au) + call assert_equal('bbxx', getline(1)) + + bwipe! + au! InsertLeave + iunmap x + endfunc *** ../vim-8.1.0503/src/version.c 2018-11-01 21:14:50.541818034 +0100 --- src/version.c 2018-11-02 11:51:43.970086497 +0100 *************** *** 794,795 **** --- 794,797 ---- { /* Add new patch number below this line */ + /**/ + 504, /**/ -- ARTHUR: Who are you? TALL KNIGHT: We are the Knights Who Say "Ni"! BEDEVERE: No! Not the Knights Who Say "Ni"! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///