aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJit <jityao+github@gmail.com>2021-09-07 06:18:33 +0800
committerGitHub <noreply@github.com>2021-09-06 15:18:33 -0700
commitdb695cc4cafa6c26eb71a183cc73a167b842731e (patch)
tree787ab119c0545975a207ba612d91247f33074555
parent687a0b3d3e8878b6de058b02d84fbd1f78aa2e89 (diff)
downloadrneovim-db695cc4cafa6c26eb71a183cc73a167b842731e.tar.gz
rneovim-db695cc4cafa6c26eb71a183cc73a167b842731e.tar.bz2
rneovim-db695cc4cafa6c26eb71a183cc73a167b842731e.zip
fix(screen): missing search highlights when redrawing from timer #15380
* Revert "vim-patch:8.1.2294: cursor pos wrong with concealing and search causes a scroll" * Add a test which covers #13074 910bbc3cca796f7fa941e0f6176cd0061de0e01c while reverting the screen.c code changes from there. Fixes #14064
-rw-r--r--src/nvim/screen.c39
-rw-r--r--test/functional/ui/syntax_conceal_spec.lua42
2 files changed, 44 insertions, 37 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 5a995b9a40..0ccf15ad4f 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -765,8 +765,6 @@ static void win_update(win_T *wp, Providers *providers)
long j;
static bool recursive = false; // being called recursively
const linenr_T old_botline = wp->w_botline;
- const int old_wrow = wp->w_wrow;
- const int old_wcol = wp->w_wcol;
// Remember what happened to the previous line.
#define DID_NONE 1 // didn't update a line
#define DID_LINE 2 // updated a normal line
@@ -1739,49 +1737,16 @@ static void win_update(win_T *wp, Providers *providers)
wp->w_valid |= VALID_BOTLINE;
wp->w_viewport_invalid = true;
if (wp == curwin && wp->w_botline != old_botline && !recursive) {
- const linenr_T old_topline = wp->w_topline;
- const int new_wcol = wp->w_wcol;
recursive = true;
curwin->w_valid &= ~VALID_TOPLINE;
update_topline(curwin); // may invalidate w_botline again
-
- if (old_wcol != new_wcol
- && (wp->w_valid & (VALID_WCOL|VALID_WROW))
- != (VALID_WCOL|VALID_WROW)) {
- // A win_line() call applied a fix to screen cursor column to
- // accommodate concealment of cursor line, but in this call to
- // update_topline() the cursor's row or column got invalidated.
- // If they are left invalid, setcursor() will recompute them
- // but there won't be any further win_line() call to re-fix the
- // column and the cursor will end up misplaced. So we call
- // cursor validation now and reapply the fix again (or call
- // win_line() to do it for us).
- validate_cursor();
- if (wp->w_wcol == old_wcol
- && wp->w_wrow == old_wrow
- && old_topline == wp->w_topline) {
- wp->w_wcol = new_wcol;
- } else {
- redrawWinline(wp, wp->w_cursor.lnum);
- }
- }
- // New redraw either due to updated topline or due to wcol fix.
- if (wp->w_redr_type != 0) {
+ if (must_redraw != 0) {
// Don't update for changes in buffer again.
i = curbuf->b_mod_set;
curbuf->b_mod_set = false;
- j = curbuf->b_mod_xlines;
- curbuf->b_mod_xlines = 0;
win_update(curwin, providers);
+ must_redraw = 0;
curbuf->b_mod_set = i;
- curbuf->b_mod_xlines = j;
- }
- // Other windows might have w_redr_type raised in update_topline().
- must_redraw = 0;
- FOR_ALL_WINDOWS_IN_TAB(wwp, curtab) {
- if (wwp->w_redr_type > must_redraw) {
- must_redraw = wwp->w_redr_type;
- }
}
recursive = false;
}
diff --git a/test/functional/ui/syntax_conceal_spec.lua b/test/functional/ui/syntax_conceal_spec.lua
index d1af0e955c..4e1852162f 100644
--- a/test/functional/ui/syntax_conceal_spec.lua
+++ b/test/functional/ui/syntax_conceal_spec.lua
@@ -913,4 +913,46 @@ describe('Screen', function()
]]}
eq(grid_lines, {{2, 0, {{'c', 0, 3}}}})
end)
+
+ -- Copy of Test_cursor_column_in_concealed_line_after_window_scroll in
+ -- test/functional/ui/syntax_conceal_spec.lua.
+ describe('concealed line after window scroll', function()
+ after_each(function()
+ command(':qall!')
+ os.remove('Xcolesearch')
+ end)
+
+ it('has the correct cursor column', function()
+ insert([[
+ 3split
+ let m = matchadd('Conceal', '=')
+ setl conceallevel=2 concealcursor=nc
+ normal gg
+ "==expr==
+ ]])
+
+ command('write Xcolesearch')
+ feed(":so %<CR>")
+
+ -- Jump to something that is beyond the bottom of the window,
+ -- so there's a scroll down.
+ feed("/expr<CR>")
+
+ -- Are the concealed parts of the current line really hidden?
+ -- Is the window's cursor column properly updated for hidden
+ -- parts of the current line?
+ screen:expect{grid=[[
+ setl conceallevel2 concealcursornc |
+ normal gg |
+ "{5:^expr} |
+ {2:Xcolesearch }|
+ normal gg |
+ "=={5:expr}== |
+ |
+ {0:~ }|
+ {3:Xcolesearch }|
+ /expr |
+ ]]}
+ end)
+ end)
end)