diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-10-26 16:21:40 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-10-26 16:21:40 +0200 |
commit | 28ed4dfe1f80905fb399c2cde31ace5ee14d8c67 (patch) | |
tree | 5af64962e98e743b85f17da32f8111c2a875ba46 /src | |
parent | 453c19257f6d97904ec2e3823e88e63c983f2f9a (diff) |
patch 8.1.2219: no autocommand for open window with terminalv8.1.2219
Problem: No autocommand for open window with terminal.
Solution: Add TerminalWinOpen. (Christian Brabandt)
Diffstat (limited to 'src')
-rw-r--r-- | src/autocmd.c | 1 | ||||
-rw-r--r-- | src/terminal.c | 2 | ||||
-rw-r--r-- | src/testdir/test_terminal.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 | ||||
-rw-r--r-- | src/vim.h | 1 |
5 files changed, 23 insertions, 0 deletions
diff --git a/src/autocmd.c b/src/autocmd.c index 3f87e931cd..6ed2971bbb 100644 --- a/src/autocmd.c +++ b/src/autocmd.c @@ -174,6 +174,7 @@ static struct event_name {"TabLeave", EVENT_TABLEAVE}, {"TermChanged", EVENT_TERMCHANGED}, {"TerminalOpen", EVENT_TERMINALOPEN}, + {"TerminalWinOpen", EVENT_TERMINALWINOPEN}, {"TermResponse", EVENT_TERMRESPONSE}, {"TextChanged", EVENT_TEXTCHANGED}, {"TextChangedI", EVENT_TEXTCHANGEDI}, diff --git a/src/terminal.c b/src/terminal.c index b50198ca5a..13e32eb5d1 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -690,6 +690,8 @@ term_start( } apply_autocmds(EVENT_TERMINALOPEN, NULL, NULL, FALSE, newbuf); + if (!opt->jo_hidden && !(flags & TERM_START_SYSTEM)) + apply_autocmds(EVENT_TERMINALWINOPEN, NULL, NULL, FALSE, newbuf); return newbuf; } diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index f506a39f68..212a15f314 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -68,6 +68,23 @@ func Test_terminal_basic() unlet g:job endfunc +func Test_terminal_TerminalWinOpen() + au TerminalWinOpen * let b:done = 'yes' + let buf = Run_shell_in_terminal({}) + call assert_equal('yes', b:done) + call StopShellInTerminal(buf) + " closing window wipes out the terminal buffer with the finished job + close + + if has("unix") + terminal ++hidden ++open sleep 1 + sleep 1 + call assert_fails("echo b:done", 'E121:') + endif + + au! TerminalWinOpen +endfunc + func Test_terminal_make_change() let buf = Run_shell_in_terminal({}) call StopShellInTerminal(buf) diff --git a/src/version.c b/src/version.c index af29302522..345fc7ae09 100644 --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2219, +/**/ 2218, /**/ 2217, @@ -1341,6 +1341,7 @@ enum auto_event EVENT_TABNEW, // when entering a new tab page EVENT_TERMCHANGED, // after changing 'term' EVENT_TERMINALOPEN, // after a terminal buffer was created + EVENT_TERMINALWINOPEN, // after a terminal buffer was created and entering its window EVENT_TERMRESPONSE, // after setting "v:termresponse" EVENT_TEXTCHANGED, // text was modified not in Insert mode EVENT_TEXTCHANGEDI, // text was modified in Insert mode |