diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-09-07 12:23:13 +0200 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2019-09-08 15:24:14 +0200 |
commit | bf9ff5148a57c64c26dd3786a4028418a6047e4a (patch) | |
tree | dcc88eeb261a46fd5f7e0dc7408a7c2ebaefe77e | |
parent | f72c7b0b3aa71aae47994112ea1d2a3697c7a1dd (diff) | |
download | rneovim-bf9ff5148a57c64c26dd3786a4028418a6047e4a.tar.gz rneovim-bf9ff5148a57c64c26dd3786a4028418a6047e4a.tar.bz2 rneovim-bf9ff5148a57c64c26dd3786a4028418a6047e4a.zip |
messages: redraw after resize in pager
note: does not "return" space at the bottom to the caller
-rw-r--r-- | src/nvim/message.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index 5b5f14b99d..30e906cd5f 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -2556,6 +2556,7 @@ static int do_more_prompt(int typed_char) int c; int retval = FALSE; int toscroll; + bool to_redraw = false; msgchunk_T *mp_last = NULL; msgchunk_T *mp; int i; @@ -2589,7 +2590,6 @@ static int do_more_prompt(int typed_char) used_typed_char = NUL; } else { c = get_keystroke(resize_events); - multiqueue_process_events(resize_events); } @@ -2663,31 +2663,44 @@ static int do_more_prompt(int typed_char) lines_left = Rows - 1; break; + case K_EVENT: + // only resize_events are processed here + // Attempt to redraw the screen. sb_text doesn't support reflow + // so this only really works for vertical resize. + multiqueue_process_events(resize_events); + to_redraw = true; + break; + default: /* no valid response */ msg_moremsg(TRUE); continue; } - if (toscroll != 0) { - if (toscroll < 0) { - /* go to start of last line */ - if (mp_last == NULL) + // code assumes we only do one at a time + assert((toscroll == 0) || !to_redraw); + + if (toscroll != 0 || to_redraw) { + if (toscroll < 0 || to_redraw) { + // go to start of last line + if (mp_last == NULL) { mp = msg_sb_start(last_msgchunk); - else if (mp_last->sb_prev != NULL) + } else if (mp_last->sb_prev != NULL) { mp = msg_sb_start(mp_last->sb_prev); - else + } else { mp = NULL; + } /* go to start of line at top of the screen */ for (i = 0; i < Rows - 2 && mp != NULL && mp->sb_prev != NULL; ++i) mp = msg_sb_start(mp->sb_prev); - if (mp != NULL && mp->sb_prev != NULL) { - /* Find line to be displayed at top. */ - for (i = 0; i > toscroll; --i) { - if (mp == NULL || mp->sb_prev == NULL) + if (mp != NULL && (mp->sb_prev != NULL || to_redraw)) { + // Find line to be displayed at top + for (i = 0; i > toscroll; i--) { + if (mp == NULL || mp->sb_prev == NULL) { break; + } mp = msg_sb_start(mp->sb_prev); if (mp_last == NULL) mp_last = msg_sb_start(last_msgchunk); @@ -2695,7 +2708,7 @@ static int do_more_prompt(int typed_char) mp_last = msg_sb_start(mp_last->sb_prev); } - if (toscroll == -1) { + if (toscroll == -1 && !to_redraw) { grid_ins_lines(&msg_grid_adj, 0, 1, Rows, 0, Columns); grid_fill(&msg_grid_adj, 0, 1, 0, Columns, ' ', ' ', HL_ATTR(HLF_MSG)); @@ -2711,6 +2724,7 @@ static int do_more_prompt(int typed_char) mp = disp_sb_line(i, mp); ++msg_scrolled; } + to_redraw = false; } toscroll = 0; } |