diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2019-09-15 16:53:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-15 16:53:43 +0200 |
commit | 45f23ef9d638504b62c50b4981643fa5f76866d7 (patch) | |
tree | 45037d5df2649904fe88cdb12d2a35110260973a | |
parent | b9d035a39cfcd61eab2633f55e6064460f557c69 (diff) | |
parent | a0f13095aab7b791853e4509516568259706377d (diff) | |
download | rneovim-45f23ef9d638504b62c50b4981643fa5f76866d7.tar.gz rneovim-45f23ef9d638504b62c50b4981643fa5f76866d7.tar.bz2 rneovim-45f23ef9d638504b62c50b4981643fa5f76866d7.zip |
Merge pull request #11025 from bfredl/doublescroll
compositor: avoid transmitting invalid lines on double scroll
-rw-r--r-- | src/nvim/ui_compositor.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/nvim/ui_compositor.c b/src/nvim/ui_compositor.c index 1af027d415..20ffc1b88e 100644 --- a/src/nvim/ui_compositor.c +++ b/src/nvim/ui_compositor.c @@ -526,9 +526,7 @@ static void ui_comp_raw_line(UI *ui, Integer grid, Integer row, endcol = MIN(endcol, clearcol); } - bool above_msg = (kv_A(layers, kv_size(layers)-1) == &msg_grid - && row < msg_current_row-(msg_was_scrolled?1:0)); - bool covered = kv_size(layers)-(above_msg?1:0) > curgrid->comp_index+1; + bool covered = curgrid_covered_above((int)row); // TODO(bfredl): eventually should just fix compose_line to respect clearing // and optimize it for uncovered lines. if (flags & kLineFlagInvalid || covered || curgrid->blending) { @@ -588,6 +586,16 @@ static void ui_comp_msg_set_pos(UI *ui, Integer grid, Integer row, msg_was_scrolled = scrolled; } +/// check if curgrid is covered on row or above +/// +/// TODO(bfredl): currently this only handles message row +static bool curgrid_covered_above(int row) +{ + bool above_msg = (kv_A(layers, kv_size(layers)-1) == &msg_grid + && row < msg_current_row-(msg_was_scrolled?1:0)); + return kv_size(layers)-(above_msg?1:0) > curgrid->comp_index+1; +} + static void ui_comp_grid_scroll(UI *ui, Integer grid, Integer top, Integer bot, Integer left, Integer right, Integer rows, Integer cols) @@ -599,18 +607,23 @@ static void ui_comp_grid_scroll(UI *ui, Integer grid, Integer top, bot += curgrid->comp_row; left += curgrid->comp_col; right += curgrid->comp_col; - bool covered = kv_size(layers) > curgrid->comp_index+1 || curgrid->blending; + bool covered = curgrid_covered_above((int)(bot - MAX(rows, 0))); - if (covered) { + if (covered || curgrid->blending) { // TODO(bfredl): // 1. check if rectangles actually overlap // 2. calulate subareas that can scroll. - if (rows > 0) { - bot -= rows; - } else { - top += (-rows); + compose_debug(top, bot, left, right, dbghl_recompose, true); + for (int r = (int)(top + MAX(-rows, 0)); r < bot - MAX(rows, 0); r++) { + // TODO(bfredl): workaround for win_update() performing two scrolls in a + // row, where the latter might scroll invalid space created by the first. + // ideally win_update() should keep track of this itself and not scroll + // the invalid space. + if (curgrid->attrs[curgrid->line_offset[r-curgrid->comp_row] + +left-curgrid->comp_col] >= 0) { + compose_line(r, left, right, 0); + } } - compose_area(top, bot, left, right); } else { ui_composed_call_grid_scroll(1, top, bot, left, right, rows, cols); if (rdb_flags & RDB_COMPOSITOR) { |