feat: trigger ModeChanged for terminal modes

This commit is contained in:
Magnus Groß 2021-10-23 20:55:52 +02:00
parent 11683193f5
commit fdfd1eda43
No known key found for this signature in database
GPG Key ID: 56A1295EB9CA7359
2 changed files with 32 additions and 0 deletions

View File

@ -412,6 +412,7 @@ void terminal_enter(void)
curwin->w_redr_status = true; // For mode() in statusline. #8323
ui_busy_start();
apply_autocmds(EVENT_TERMENTER, NULL, NULL, false, curbuf);
trigger_modechanged();
s->state.execute = terminal_execute;
s->state.check = terminal_check;

View File

@ -0,0 +1,31 @@
local helpers = require('test.functional.helpers')(after_each)
local clear, eval, eq = helpers.clear, helpers.eval, helpers.eq
local feed, command = helpers.feed, helpers.command
describe('ModeChanged', function()
before_each(function()
clear()
command('let g:count = 0')
command('au ModeChanged * let g:event = copy(v:event)')
command('au ModeChanged * let g:count += 1')
end)
it('picks up terminal mode changes', function()
command("term")
feed('i')
eq({
old_mode = 'nt',
new_mode = 't'
}, eval('g:event'))
feed('<c-\\><c-n>')
eq({
old_mode = 't',
new_mode = 'nt'
}, eval('g:event'))
eq(3, eval('g:count'))
command("bd!")
-- v:event is cleared after the autocommand is done
eq({}, eval('v:event'))
end)
end)