mirror of
https://github.com/neovim/neovim
synced 2025-07-16 17:21:49 +00:00
fix(events)!: trigger CursorMoved later on switching window (#23711)
This commit is contained in:
@ -505,8 +505,7 @@ CursorMoved After the cursor was moved in Normal or Visual
|
|||||||
"x", "rx" or "p".
|
"x", "rx" or "p".
|
||||||
Not always triggered when there is typeahead,
|
Not always triggered when there is typeahead,
|
||||||
while executing commands in a script file, or
|
while executing commands in a script file, or
|
||||||
when an operator is pending. Always triggered
|
when an operator is pending.
|
||||||
when moving to another window.
|
|
||||||
For an example see |match-parens|.
|
For an example see |match-parens|.
|
||||||
Note: Cannot be skipped with |:noautocmd|.
|
Note: Cannot be skipped with |:noautocmd|.
|
||||||
Careful: This is triggered very often, don't
|
Careful: This is triggered very often, don't
|
||||||
|
@ -30,6 +30,8 @@ The following changes may require adaptations in user config or plugins.
|
|||||||
set mousemodel=popup
|
set mousemodel=popup
|
||||||
set keymodel=startsel,stopsel
|
set keymodel=startsel,stopsel
|
||||||
<
|
<
|
||||||
|
• When switching windows, |CursorMoved| autocommands trigger when Nvim is back
|
||||||
|
in the main loop rather than immediately. This is more compatible with Vim.
|
||||||
|
|
||||||
• |LspRequest| autocmd was promoted from a |User| autocmd to a first class
|
• |LspRequest| autocmd was promoted from a |User| autocmd to a first class
|
||||||
citizen.
|
citizen.
|
||||||
|
@ -4903,8 +4903,7 @@ static void win_enter_ext(win_T *const wp, const int flags)
|
|||||||
if (other_buffer) {
|
if (other_buffer) {
|
||||||
apply_autocmds(EVENT_BUFENTER, NULL, NULL, false, curbuf);
|
apply_autocmds(EVENT_BUFENTER, NULL, NULL, false, curbuf);
|
||||||
}
|
}
|
||||||
apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, false, curbuf);
|
curwin->w_last_cursormoved.lnum = 0;
|
||||||
curwin->w_last_cursormoved = curwin->w_cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
maketitle();
|
maketitle();
|
||||||
|
@ -5,19 +5,23 @@ local eq = helpers.eq
|
|||||||
local eval = helpers.eval
|
local eval = helpers.eval
|
||||||
local funcs = helpers.funcs
|
local funcs = helpers.funcs
|
||||||
local source = helpers.source
|
local source = helpers.source
|
||||||
|
local command = helpers.command
|
||||||
|
|
||||||
describe('CursorMoved', function()
|
describe('CursorMoved', function()
|
||||||
before_each(clear)
|
before_each(clear)
|
||||||
|
|
||||||
it('is triggered by changing windows', function()
|
it('is triggered after BufEnter when changing or splitting windows #11878 #12031', function()
|
||||||
source([[
|
source([[
|
||||||
let g:cursormoved = 0
|
call setline(1, 'foo')
|
||||||
vsplit
|
let g:log = []
|
||||||
autocmd CursorMoved * let g:cursormoved += 1
|
autocmd BufEnter * let g:log += ['BufEnter' .. expand("<abuf>")]
|
||||||
wincmd w
|
autocmd CursorMoved * let g:log += ['CursorMoved' .. expand("<abuf>")]
|
||||||
wincmd w
|
|
||||||
]])
|
]])
|
||||||
eq(2, eval('g:cursormoved'))
|
eq({}, eval('g:log'))
|
||||||
|
command('new')
|
||||||
|
eq({'BufEnter2', 'CursorMoved2'}, eval('g:log'))
|
||||||
|
command('wincmd w')
|
||||||
|
eq({'BufEnter2', 'CursorMoved2', 'BufEnter1', 'CursorMoved1'}, eval('g:log'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("is not triggered by functions that don't change the window", function()
|
it("is not triggered by functions that don't change the window", function()
|
||||||
|
@ -79,7 +79,7 @@ describe('float window', function()
|
|||||||
api.nvim_buf_set_lines(buf, 0, -1, true, contents)
|
api.nvim_buf_set_lines(buf, 0, -1, true, contents)
|
||||||
local winnr = vim.fn.win_id2win(floatwin)
|
local winnr = vim.fn.win_id2win(floatwin)
|
||||||
api.nvim_command('wincmd p')
|
api.nvim_command('wincmd p')
|
||||||
api.nvim_command('autocmd CursorMoved * ++once '..winnr..'wincmd c')
|
api.nvim_command('autocmd BufEnter * ++once '..winnr..'wincmd c')
|
||||||
return buf, floatwin
|
return buf, floatwin
|
||||||
end
|
end
|
||||||
crashes{'foo'}
|
crashes{'foo'}
|
||||||
|
Reference in New Issue
Block a user