Mercurial > vim
diff src/terminal.c @ 30843:82e62fd4eae9 v9.0.0756
patch 9.0.0756: no autocmd event for changing text in a terminal window
Commit: https://github.com/vim/vim/commit/4ccaedfcd7526983f4b6b3b06b0bfb54f333f1f3
Author: Shougo Matsushita <Shougo.Matsu@gmail.com>
Date: Sat Oct 15 11:48:00 2022 +0100
patch 9.0.0756: no autocmd event for changing text in a terminal window
Problem: No autocmd event for changing text in a terminal window.
Solution: Add TextChangedT. (Shougo Matsushita, closes https://github.com/vim/vim/issues/11366)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 15 Oct 2022 13:00:02 +0200 |
parents | c7983f593fa7 |
children | 82336c3b679d |
line wrap: on
line diff
--- 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; } }