aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/autocmd.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-11 16:24:15 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-04-12 05:02:05 +0800
commit53668a5815099f432a5ecebad1d2982ae6813fe6 (patch)
tree0b5e1c37347294ef12e65f4315f3bc95c5cccf89 /src/nvim/autocmd.c
parent10b40440ddbdc979a47335790988966b4e9fb6f1 (diff)
downloadrneovim-53668a5815099f432a5ecebad1d2982ae6813fe6.tar.gz
rneovim-53668a5815099f432a5ecebad1d2982ae6813fe6.tar.bz2
rneovim-53668a5815099f432a5ecebad1d2982ae6813fe6.zip
vim-patch:8.2.4713: plugins cannot track text scrolling
Problem: Plugins cannot track text scrolling. Solution: Add the WinScrolled event. (closes vim/vim#10102) https://github.com/vim/vim/commit/0937182d49fa8db50cec42785f22f1031760a0bd Skip User event in autocmd.txt, not needed unless #10689 is reverted.
Diffstat (limited to 'src/nvim/autocmd.c')
-rw-r--r--src/nvim/autocmd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index f65b5ba983..1b146f82c6 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -1092,6 +1092,15 @@ int autocmd_register(int64_t id, event_T event, char_u *pat, int patlen, int gro
curwin->w_last_cursormoved = curwin->w_cursor;
}
+ // Initialize the fields checked by the WinScrolled trigger to
+ // stop it from firing right after the first autocmd is defined.
+ if (event == EVENT_WINSCROLLED && !has_event(EVENT_WINSCROLLED)) {
+ curwin->w_last_topline = curwin->w_topline;
+ curwin->w_last_leftcol = curwin->w_leftcol;
+ curwin->w_last_width = curwin->w_width;
+ curwin->w_last_height = curwin->w_height;
+ }
+
ap->cmds = NULL;
*prev_ap = ap;
last_autopat[(int)event] = ap;
@@ -1718,7 +1727,7 @@ bool apply_autocmds_group(event_T event, char_u *fname, char_u *fname_io, bool f
|| event == EVENT_REMOTEREPLY || event == EVENT_SPELLFILEMISSING
|| event == EVENT_SYNTAX || event == EVENT_SIGNAL
|| event == EVENT_TABCLOSED || event == EVENT_USER
- || event == EVENT_WINCLOSED) {
+ || event == EVENT_WINCLOSED || event == EVENT_WINSCROLLED) {
fname = vim_strsave(fname);
} else {
fname = (char_u *)FullName_save((char *)fname, false);