diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2022-10-15 11:48:00 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-15 11:48:00 +0100 |
commit | 4ccaedfcd7526983f4b6b3b06b0bfb54f333f1f3 (patch) | |
tree | ba5cebcced4528b7a7ce20ccc5f546f4bd8585ed /src/terminal.c | |
parent | d988ef3a555df2c686899a74393ed53b3186370c (diff) |
patch 9.0.0756: no autocmd event for changing text in a terminal windowv9.0.0756
Problem: No autocmd event for changing text in a terminal window.
Solution: Add TextChangedT. (Shougo Matsushita, closes #11366)
Diffstat (limited to 'src/terminal.c')
-rw-r--r-- | src/terminal.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/terminal.c b/src/terminal.c index ae532dc721..d9f1e0f821 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1222,6 +1222,8 @@ update_cursor(term_T *term, int redraw) setcursor(); if (redraw) { + aco_save_T aco; + if (term->tl_buffer == curbuf && term->tl_cursor_visible) cursor_on(); out_flush(); @@ -1232,6 +1234,16 @@ update_cursor(term_T *term, int redraw) gui_mch_flush(); } #endif + // Make sure an invoked autocmd doesn't delete the buffer (and the + // terminal) under our fingers. + ++term->tl_buffer->b_locked; + + // save and restore curwin and curbuf, in case the autocmd changes them + aucmd_prepbuf(&aco, curbuf); + apply_autocmds(EVENT_TEXTCHANGEDT, NULL, NULL, FALSE, term->tl_buffer); + aucmd_restbuf(&aco); + + --term->tl_buffer->b_locked; } } |