aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/normal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/normal.c')
-rw-r--r--src/nvim/normal.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 11e8d354e4..771ca732f4 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1197,6 +1197,15 @@ static void normal_check_interrupt(NormalState *s)
}
}
+static void normal_check_window_scrolled(NormalState *s)
+{
+ // Trigger Scroll if the viewport changed.
+ if (!finish_op && has_event(EVENT_WINSCROLLED)
+ && win_did_scroll(curwin)) {
+ do_autocmd_winscrolled(curwin);
+ }
+}
+
static void normal_check_cursor_moved(NormalState *s)
{
// Trigger CursorMoved if the cursor moved.
@@ -1320,8 +1329,13 @@ static int normal_check(VimState *state)
if (skip_redraw || exmode_active) {
skip_redraw = false;
} else if (do_redraw || stuff_empty()) {
+ // Need to make sure w_topline and w_leftcol are correct before
+ // normal_check_window_scrolled() is called.
+ update_topline();
+
normal_check_cursor_moved(s);
normal_check_text_changed(s);
+ normal_check_window_scrolled(s);
// Updating diffs from changed() does not always work properly,
// esp. updating folds. Do an update just before redrawing if
@@ -4111,10 +4125,10 @@ void scroll_redraw(int up, long count)
int prev_topfill = curwin->w_topfill;
linenr_T prev_lnum = curwin->w_cursor.lnum;
- if (up)
- scrollup(count, true);
- else
+ bool moved = up ?
+ scrollup(count, true) :
scrolldown(count, true);
+
if (get_scrolloff_value()) {
// Adjust the cursor position for 'scrolloff'. Mark w_topline as
// valid, otherwise the screen jumps back at the end of the file.
@@ -4144,9 +4158,12 @@ void scroll_redraw(int up, long count)
curwin->w_valid |= VALID_TOPLINE;
}
}
- if (curwin->w_cursor.lnum != prev_lnum)
+ if (curwin->w_cursor.lnum != prev_lnum) {
coladvance(curwin->w_curswant);
- curwin->w_viewport_invalid = true;
+ }
+ if (moved) {
+ curwin->w_viewport_invalid = true;
+ }
redraw_later(curwin, VALID);
}