mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 9.0.2075: TextChangedI may not always trigger
Problem: TextChangedI may not always trigger Solution: trigger it in more cases: for insert/ append/change operations, and when opening a new line, fixes: #13367 closes: #13375 Signed-off-by: Christian Brabandt <cb@256bit.org> Signed-off-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com>
This commit is contained in:
parent
daef8c7437
commit
4bca4897a1
@ -174,9 +174,6 @@ edit(
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ins_compl_clear(); // clear stuff for CTRL-X mode
|
ins_compl_clear(); // clear stuff for CTRL-X mode
|
||||||
// Reset Changedtick_i, so that TextChangedI will only be triggered for stuff
|
|
||||||
// from insert mode
|
|
||||||
curbuf->b_last_changedtick_i = CHANGEDTICK(curbuf);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx".
|
* Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx".
|
||||||
|
@ -6292,6 +6292,8 @@ n_opencmd(cmdarg_T *cap)
|
|||||||
(void)hasFolding(curwin->w_cursor.lnum,
|
(void)hasFolding(curwin->w_cursor.lnum,
|
||||||
NULL, &curwin->w_cursor.lnum);
|
NULL, &curwin->w_cursor.lnum);
|
||||||
#endif
|
#endif
|
||||||
|
// trigger TextChangedI for the 'o/O' command
|
||||||
|
curbuf->b_last_changedtick_i = CHANGEDTICK(curbuf);
|
||||||
if (u_save((linenr_T)(curwin->w_cursor.lnum -
|
if (u_save((linenr_T)(curwin->w_cursor.lnum -
|
||||||
(cap->cmdchar == 'O' ? 1 : 0)),
|
(cap->cmdchar == 'O' ? 1 : 0)),
|
||||||
(linenr_T)(curwin->w_cursor.lnum +
|
(linenr_T)(curwin->w_cursor.lnum +
|
||||||
@ -7083,6 +7085,10 @@ invoke_edit(
|
|||||||
// Always reset "restart_edit", this is not a restarted edit.
|
// Always reset "restart_edit", this is not a restarted edit.
|
||||||
restart_edit = 0;
|
restart_edit = 0;
|
||||||
|
|
||||||
|
// Reset Changedtick_i, so that TextChangedI will only be triggered for stuff
|
||||||
|
// from insert mode, for 'o/O' this has already been done in n_opencmd
|
||||||
|
if (cap->cmdchar != 'O' && cap->cmdchar != 'o')
|
||||||
|
curbuf->b_last_changedtick_i = CHANGEDTICK(curbuf);
|
||||||
if (edit(cmd, startln, cap->count1))
|
if (edit(cmd, startln, cap->count1))
|
||||||
cap->retval |= CA_COMMAND_BUSY;
|
cap->retval |= CA_COMMAND_BUSY;
|
||||||
|
|
||||||
|
@ -4134,6 +4134,9 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
|
|||||||
// before.
|
// before.
|
||||||
restore_lbr(lbr_saved);
|
restore_lbr(lbr_saved);
|
||||||
#endif
|
#endif
|
||||||
|
// trigger TextChangedI
|
||||||
|
curbuf->b_last_changedtick_i = CHANGEDTICK(curbuf);
|
||||||
|
|
||||||
if (op_change(oap)) // will call edit()
|
if (op_change(oap)) // will call edit()
|
||||||
cap->retval |= CA_COMMAND_BUSY;
|
cap->retval |= CA_COMMAND_BUSY;
|
||||||
if (restart_edit == 0)
|
if (restart_edit == 0)
|
||||||
@ -4244,6 +4247,9 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank)
|
|||||||
// before.
|
// before.
|
||||||
restore_lbr(lbr_saved);
|
restore_lbr(lbr_saved);
|
||||||
#endif
|
#endif
|
||||||
|
// trigger TextChangedI
|
||||||
|
curbuf->b_last_changedtick_i = CHANGEDTICK(curbuf);
|
||||||
|
|
||||||
op_insert(oap, cap->count1);
|
op_insert(oap, cap->count1);
|
||||||
#ifdef FEAT_LINEBREAK
|
#ifdef FEAT_LINEBREAK
|
||||||
// Reset linebreak, so that formatting works correctly.
|
// Reset linebreak, so that formatting works correctly.
|
||||||
|
@ -2566,28 +2566,27 @@ func Test_ChangedP()
|
|||||||
call cursor(3, 1)
|
call cursor(3, 1)
|
||||||
let g:autocmd = ''
|
let g:autocmd = ''
|
||||||
call feedkeys("o\<esc>", 'tnix')
|
call feedkeys("o\<esc>", 'tnix')
|
||||||
" `TextChangedI` triggers only if text is actually changed in Insert mode
|
|
||||||
call assert_equal('', g:autocmd)
|
|
||||||
|
|
||||||
let g:autocmd = ''
|
|
||||||
call feedkeys("Sf", 'tnix')
|
|
||||||
call assert_equal('I', g:autocmd)
|
call assert_equal('I', g:autocmd)
|
||||||
|
|
||||||
|
let g:autocmd = ''
|
||||||
|
call feedkeys("Sf", 'tnix')
|
||||||
|
call assert_equal('II', g:autocmd)
|
||||||
|
|
||||||
let g:autocmd = ''
|
let g:autocmd = ''
|
||||||
call feedkeys("Sf\<C-N>", 'tnix')
|
call feedkeys("Sf\<C-N>", 'tnix')
|
||||||
call assert_equal('IP', g:autocmd)
|
call assert_equal('IIP', g:autocmd)
|
||||||
|
|
||||||
let g:autocmd = ''
|
let g:autocmd = ''
|
||||||
call feedkeys("Sf\<C-N>\<C-N>", 'tnix')
|
call feedkeys("Sf\<C-N>\<C-N>", 'tnix')
|
||||||
call assert_equal('IPP', g:autocmd)
|
call assert_equal('IIPP', g:autocmd)
|
||||||
|
|
||||||
let g:autocmd = ''
|
let g:autocmd = ''
|
||||||
call feedkeys("Sf\<C-N>\<C-N>\<C-N>", 'tnix')
|
call feedkeys("Sf\<C-N>\<C-N>\<C-N>", 'tnix')
|
||||||
call assert_equal('IPPP', g:autocmd)
|
call assert_equal('IIPPP', g:autocmd)
|
||||||
|
|
||||||
let g:autocmd = ''
|
let g:autocmd = ''
|
||||||
call feedkeys("Sf\<C-N>\<C-N>\<C-N>\<C-N>", 'tnix')
|
call feedkeys("Sf\<C-N>\<C-N>\<C-N>\<C-N>", 'tnix')
|
||||||
call assert_equal('IPPPP', g:autocmd)
|
call assert_equal('IIPPPP', g:autocmd)
|
||||||
|
|
||||||
call assert_equal(['foo', 'bar', 'foobar', 'foo'], getline(1, '$'))
|
call assert_equal(['foo', 'bar', 'foobar', 'foo'], getline(1, '$'))
|
||||||
" TODO: how should it handle completeopt=noinsert,noselect?
|
" TODO: how should it handle completeopt=noinsert,noselect?
|
||||||
@ -3621,6 +3620,25 @@ func Test_Changed_ChangedI()
|
|||||||
call feedkeys("ibar\<esc>", 'tnix')
|
call feedkeys("ibar\<esc>", 'tnix')
|
||||||
call assert_equal('', g:autocmd_n)
|
call assert_equal('', g:autocmd_n)
|
||||||
|
|
||||||
|
" If change is a mix of Normal and Insert modes, TextChangedI should trigger
|
||||||
|
func s:validate_mixed_textchangedi(keys)
|
||||||
|
call feedkeys("ifoo\<esc>", 'tnix')
|
||||||
|
let g:autocmd_i = ''
|
||||||
|
let g:autocmd_n = ''
|
||||||
|
call feedkeys(a:keys, 'tnix')
|
||||||
|
call assert_notequal('', g:autocmd_i)
|
||||||
|
call assert_equal('', g:autocmd_n)
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
call s:validate_mixed_textchangedi("o\<esc>")
|
||||||
|
call s:validate_mixed_textchangedi("O\<esc>")
|
||||||
|
call s:validate_mixed_textchangedi("ciw\<esc>")
|
||||||
|
call s:validate_mixed_textchangedi("cc\<esc>")
|
||||||
|
call s:validate_mixed_textchangedi("C\<esc>")
|
||||||
|
call s:validate_mixed_textchangedi("s\<esc>")
|
||||||
|
call s:validate_mixed_textchangedi("S\<esc>")
|
||||||
|
|
||||||
|
|
||||||
" CleanUp
|
" CleanUp
|
||||||
call test_override("char_avail", 0)
|
call test_override("char_avail", 0)
|
||||||
au! TextChanged <buffer>
|
au! TextChanged <buffer>
|
||||||
|
@ -704,6 +704,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2075,
|
||||||
/**/
|
/**/
|
||||||
2074,
|
2074,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user