aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-09-03 19:27:12 +0200
committerBjörn Linse <bjorn.linse@gmail.com>2019-09-06 19:38:07 +0200
commit5c8a57da81a02e200fbe76a1981e529e2e907d4c (patch)
treefacae42b7525ac3c63dc41687666b4ec2f9fc5bb
parent72d7099abdb9128b9aafd2e5a621ae95454e1174 (diff)
downloadrneovim-5c8a57da81a02e200fbe76a1981e529e2e907d4c.tar.gz
rneovim-5c8a57da81a02e200fbe76a1981e529e2e907d4c.tar.bz2
rneovim-5c8a57da81a02e200fbe76a1981e529e2e907d4c.zip
messages: fix crashes with scrollback
-rw-r--r--src/nvim/message.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 9bd4b44e3a..c499aa5f0c 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -2217,37 +2217,36 @@ void msg_scroll_up(bool may_throttle)
/// we get throttling "for free" using standard redraw_win_later code paths.
void msg_scroll_flush(void)
{
- if (!msg_grid.throttled) {
- return;
- }
- msg_grid.throttled = false;
- int pos_delta = msg_grid_pos_at_flush - msg_grid_pos;
- assert(pos_delta >= 0);
- int delta = MIN(msg_scrolled - msg_scrolled_at_flush, msg_grid.Rows);
+ if (msg_grid.throttled) {
+ msg_grid.throttled = false;
+ int pos_delta = msg_grid_pos_at_flush - msg_grid_pos;
+ assert(pos_delta >= 0);
+ int delta = MIN(msg_scrolled - msg_scrolled_at_flush, msg_grid.Rows);
- if (pos_delta > 0) {
- ui_ext_msg_set_pos(msg_grid_pos, true);
- msg_grid_pos_at_flush = msg_grid_pos;
- }
+ if (pos_delta > 0) {
+ ui_ext_msg_set_pos(msg_grid_pos, true);
+ }
- int to_scroll = delta-pos_delta-msg_grid_scroll_discount;
- assert(to_scroll >= 0);
+ int to_scroll = delta-pos_delta-msg_grid_scroll_discount;
+ assert(to_scroll >= 0);
- // TODO(bfredl): msg_grid_pos should be 0 already when starting scrolling
- // but this sometimes fails in "headless" message printing.
- if (to_scroll > 0 && msg_grid_pos == 0) {
- ui_call_grid_scroll(msg_grid.handle, 0, Rows, 0, Columns, to_scroll, 0);
- }
+ // TODO(bfredl): msg_grid_pos should be 0 already when starting scrolling
+ // but this sometimes fails in "headless" message printing.
+ if (to_scroll > 0 && msg_grid_pos == 0) {
+ ui_call_grid_scroll(msg_grid.handle, 0, Rows, 0, Columns, to_scroll, 0);
+ }
- for (int i = MAX(Rows-MAX(delta, 1), 0); i < Rows; i++) {
- int row = i-msg_grid_pos;
- assert(row >= 0);
- ui_line(&msg_grid, row, 0, msg_grid.dirty_col[row], msg_grid.Columns,
- HL_ATTR(HLF_MSG), false);
- msg_grid.dirty_col[row] = 0;
+ for (int i = MAX(Rows-MAX(delta, 1), 0); i < Rows; i++) {
+ int row = i-msg_grid_pos;
+ assert(row >= 0);
+ ui_line(&msg_grid, row, 0, msg_grid.dirty_col[row], msg_grid.Columns,
+ HL_ATTR(HLF_MSG), false);
+ msg_grid.dirty_col[row] = 0;
+ }
}
msg_scrolled_at_flush = msg_scrolled;
msg_grid_scroll_discount = 0;
+ msg_grid_pos_at_flush = msg_grid_pos;
}
void msg_reset_scroll(void)