diff options
-rw-r--r-- | src/nvim/window.c | 13 | ||||
-rw-r--r-- | test/functional/autocmd/tabnewentered_spec.lua | 9 |
2 files changed, 17 insertions, 5 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c index 4eaba3a3df..1298248f1e 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -251,11 +251,14 @@ newwindow: if (win_new_tabpage((int)Prenum, NULL) == OK && valid_tabpage(oldtab)) { newtab = curtab; - goto_tabpage_tp(oldtab, TRUE, TRUE); - if (curwin == wp) - win_close(curwin, FALSE); - if (valid_tabpage(newtab)) - goto_tabpage_tp(newtab, TRUE, TRUE); + goto_tabpage_tp(oldtab, true, true); + if (curwin == wp) { + win_close(curwin, false); + } + if (valid_tabpage(newtab)) { + goto_tabpage_tp(newtab, true, true); + apply_autocmds(EVENT_TABNEWENTERED, NULL, NULL, false, curbuf); + } } } break; diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua index 53bbca9f39..7fa3dddb93 100644 --- a/test/functional/autocmd/tabnewentered_spec.lua +++ b/test/functional/autocmd/tabnewentered_spec.lua @@ -18,5 +18,14 @@ describe('TabNewEntered', function() eq("\n\""..tmp_path.."\" [New File]\ntabnewentered:4:4\ntabnewentered:match", nvim('command_output', 'tabnew '..tmp_path)) end) end) + describe('with CTRL-W T', function() + it('works when opening a new tab with CTRL-W T', function() + clear() + nvim('command', 'au! TabNewEntered * echom "entered"') + nvim('command', 'tabnew test.x2') + nvim('command', 'split') + eq('\nentered', nvim('command_output', 'execute "normal \\<C-W>T"')) + end) + end) end) end) |