implement scroll autocommand

This commit is contained in:
Rom Grk
2020-10-19 12:27:17 -04:00
parent 0f590ae2a8
commit b83d8223ff
4 changed files with 48 additions and 0 deletions

View File

@@ -1482,6 +1482,31 @@ static void ins_redraw(
}
}
if (ready && has_event(EVENT_SCROLL)
&& (curwin->w_last_topline != curwin->w_topline ||
curwin->w_last_leftcol != curwin->w_leftcol)) {
// XXX is the buf changedtick thing necessary?
// XXX apply_autocmds vs ins_apply_autocmds?
// XXX why can't we re-use normal_check_window_scrolled()?
aco_save_T aco;
varnumber_T tick = buf_get_changedtick(curbuf);
// save and restore curwin and curbuf, in case the autocmd changes them
aucmd_prepbuf(&aco, curbuf);
apply_autocmds(EVENT_SCROLL, NULL, NULL, false, curbuf);
aucmd_restbuf(&aco);
curbuf->b_last_changedtick_pum = buf_get_changedtick(curbuf);
if (tick != buf_get_changedtick(curbuf)) { // see ins_apply_autocmds()
u_save(curwin->w_cursor.lnum,
(linenr_T)(curwin->w_cursor.lnum + 1));
}
curwin->w_last_topline = curwin->w_topline;
curwin->w_last_leftcol = curwin->w_leftcol;
}
if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin)
&& conceal_cursor_moved) {
redrawWinline(curwin, curwin->w_cursor.lnum);