summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-03-27 19:26:55 +0100
committerBram Moolenaar <Bram@vim.org>2022-03-27 19:26:55 +0100
commit3e559cd88486ffab6b6fb4e0921b4600d137a617 (patch)
tree282c592a9ddd18ff55bbe6c4094157167f86bfda
parent565d1278cbbb7bc927bee207d5c2bc0bb95928fa (diff)
downloadvim-git-3e559cd88486ffab6b6fb4e0921b4600d137a617.tar.gz
patch 8.2.4638: superfluous check if a redraw is needed for 'cursorline'v8.2.4639v8.2.4638
Problem: Superfluous check if a redraw is needed for 'cursorline'. Solution: Remove check_redraw_cursorline(). (closes #10030, closes #10029)
-rw-r--r--src/drawscreen.c24
-rw-r--r--src/edit.c4
-rw-r--r--src/main.c4
-rw-r--r--src/move.c30
-rw-r--r--src/normal.c4
-rw-r--r--src/proto/drawscreen.pro1
-rw-r--r--src/testdir/dumps/Test_cursorcolumn_callback_1.dump8
-rw-r--r--src/testdir/dumps/Test_relativenumber_callback_1.dump8
-rw-r--r--src/testdir/test_highlight.vim25
-rw-r--r--src/testdir/test_number.vim25
-rw-r--r--src/version.c2
11 files changed, 94 insertions, 41 deletions
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 12eed8c47..cb4757748 100644
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -3032,23 +3032,6 @@ redraw_asap(int type)
}
#endif
-#if defined(FEAT_SYN_HL) || defined(PROTO)
-/*
- * Check if the cursor moved and 'cursorline' is set. Mark for a VALID redraw
- * if needed.
- */
- void
-check_redraw_cursorline(void)
-{
- // When 'cursorlineopt' is "screenline" need to redraw always.
- if (curwin->w_p_cul
- && (curwin->w_last_cursorline != curwin->w_cursor.lnum
- || (curwin->w_p_culopt_flags & CULOPT_SCRLINE))
- && !char_avail())
- redraw_later(VALID);
-}
-#endif
-
/*
* Invoked after an asynchronous callback is called.
* If an echo command was used the cursor needs to be put back where
@@ -3093,10 +3076,9 @@ redraw_after_callback(int call_update_screen, int do_message)
}
else if (State & (NORMAL | INSERT | TERMINAL))
{
-#ifdef FEAT_SYN_HL
- // might need to update for 'cursorline'
- check_redraw_cursorline();
-#endif
+ update_topline();
+ validate_cursor();
+
// keep the command line if possible
update_screen(VALID_NO_UPDATE);
setcursor();
diff --git a/src/edit.c b/src/edit.c
index a183324b3..0edd38be4 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -1058,10 +1058,6 @@ doESCkey:
case K_COMMAND: // <Cmd>command<CR>
case K_SCRIPT_COMMAND: // <ScriptCmd>command<CR>
do_cmdkey_command(c, 0);
-#ifdef FEAT_SYN_HL
- // Might need to update for 'cursorline'.
- check_redraw_cursorline();
-#endif
#ifdef FEAT_TERMINAL
if (term_use_loop())
// Started a terminal that gets the input, exit Insert mode.
diff --git a/src/main.c b/src/main.c
index 7e8cbf08e..cf582e9df 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1384,10 +1384,6 @@ main_loop(
update_topline();
validate_cursor();
-#ifdef FEAT_SYN_HL
- // Might need to update for 'cursorline'.
- check_redraw_cursorline();
-#endif
if (VIsual_active)
update_curbuf(INVERTED); // update inverted part
else if (must_redraw)
diff --git a/src/move.c b/src/move.c
index 571ec8c31..3d8356fe9 100644
--- a/src/move.c
+++ b/src/move.c
@@ -135,6 +135,26 @@ redraw_for_cursorline(win_T *wp)
}
}
+#ifdef FEAT_SYN_HL
+/*
+ * Redraw when w_virtcol changes and 'cursorcolumn' is set or 'cursorlineopt'
+ * contains "screenline".
+ */
+ static void
+redraw_for_cursorcolumn(win_T *wp)
+{
+ if ((wp->w_valid & VALID_VIRTCOL) == 0 && !pum_visible())
+ {
+ // When 'cursorcolumn' is set need to redraw with SOME_VALID.
+ if (wp->w_p_cuc)
+ redraw_later(SOME_VALID);
+ // When 'cursorlineopt' contains "screenline" need to redraw with VALID.
+ else if (wp->w_p_cul && (wp->w_p_culopt_flags & CULOPT_SCRLINE))
+ redraw_later(VALID);
+ }
+}
+#endif
+
/*
* Update curwin->w_topline and redraw if necessary.
* Used to update the screen before printing a message.
@@ -798,11 +818,10 @@ validate_virtcol_win(win_T *wp)
if (!(wp->w_valid & VALID_VIRTCOL))
{
getvvcol(wp, &wp->w_cursor, NULL, &(wp->w_virtcol), NULL);
- wp->w_valid |= VALID_VIRTCOL;
#ifdef FEAT_SYN_HL
- if (wp->w_p_cuc && !pum_visible())
- redraw_win_later(wp, SOME_VALID);
+ redraw_for_cursorcolumn(wp);
#endif
+ wp->w_valid |= VALID_VIRTCOL;
}
}
@@ -1169,10 +1188,7 @@ curs_columns(
redraw_later(NOT_VALID);
#ifdef FEAT_SYN_HL
- // Redraw when w_virtcol changes and 'cursorcolumn' is set
- if (curwin->w_p_cuc && (curwin->w_valid & VALID_VIRTCOL) == 0
- && !pum_visible())
- redraw_later(SOME_VALID);
+ redraw_for_cursorcolumn(curwin);
#endif
#if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL)
if (popup_is_popup(curwin) && curbuf->b_term != NULL)
diff --git a/src/normal.c b/src/normal.c
index 49e5a93b1..e39fb772a 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -6971,10 +6971,6 @@ nv_edit(cmdarg_T *cap)
coladvance(getviscol());
State = save_State;
}
-#ifdef FEAT_SYN_HL
- // Might need to update for 'cursorline'.
- check_redraw_cursorline();
-#endif
invoke_edit(cap, FALSE, cap->cmdchar, FALSE);
}
diff --git a/src/proto/drawscreen.pro b/src/proto/drawscreen.pro
index 573a2a4c0..c83501986 100644
--- a/src/proto/drawscreen.pro
+++ b/src/proto/drawscreen.pro
@@ -8,7 +8,6 @@ void update_curbuf(int type);
void update_debug_sign(buf_T *buf, linenr_T lnum);
void updateWindow(win_T *wp);
int redraw_asap(int type);
-void check_redraw_cursorline(void);
void redraw_after_callback(int call_update_screen, int do_message);
void redraw_later(int type);
void redraw_win_later(win_T *wp, int type);
diff --git a/src/testdir/dumps/Test_cursorcolumn_callback_1.dump b/src/testdir/dumps/Test_cursorcolumn_callback_1.dump
new file mode 100644
index 000000000..7b1b85b67
--- /dev/null
+++ b/src/testdir/dumps/Test_cursorcolumn_callback_1.dump
@@ -0,0 +1,8 @@
+>a+0&#ffffff0@4| @69
+|b+0&#e0e0e08|b+0&#ffffff0@3| @69
+|c+0&#e0e0e08|c+0&#ffffff0@3| @69
+|d+0&#e0e0e08|d+0&#ffffff0@3| @69
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|4|,|5| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_relativenumber_callback_1.dump b/src/testdir/dumps/Test_relativenumber_callback_1.dump
new file mode 100644
index 000000000..f25612d34
--- /dev/null
+++ b/src/testdir/dumps/Test_relativenumber_callback_1.dump
@@ -0,0 +1,8 @@
+| +0#af5f00255#ffffff0@1|0| >a+0#0000000&@4| @65
+| +0#af5f00255&@1|1| |b+0#0000000&@4| @65
+| +0#af5f00255&@1|2| |c+0#0000000&@4| @65
+| +0#af5f00255&@1|3| |d+0#0000000&@4| @65
+|~+0#4040ff13&| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|4|,|1| @10|A|l@1|
diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim
index 8b3bcdc39..b07ba1174 100644
--- a/src/testdir/test_highlight.vim
+++ b/src/testdir/test_highlight.vim
@@ -592,6 +592,31 @@ func Test_cursorline_with_visualmode()
call delete('Xtest_cursorline_with_visualmode')
endfunc
+func Test_cursorcolumn_callback()
+ CheckScreendump
+ CheckFeature timers
+
+ let lines =<< trim END
+ call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'])
+ set cursorcolumn
+ call cursor(4, 5)
+
+ func Func(timer)
+ call cursor(1, 1)
+ endfunc
+
+ call timer_start(300, 'Func')
+ END
+ call writefile(lines, 'Xcuc_timer')
+
+ let buf = RunVimInTerminal('-S Xcuc_timer', #{rows: 8})
+ call TermWait(buf, 310)
+ call VerifyScreenDump(buf, 'Test_cursorcolumn_callback_1', {})
+
+ call StopVimInTerminal(buf)
+ call delete('Xcuc_timer')
+endfunc
+
func Test_wincolor()
CheckScreendump
" make sure the width is enough for the test
diff --git a/src/testdir/test_number.vim b/src/testdir/test_number.vim
index 78cd6f901..c2cce963f 100644
--- a/src/testdir/test_number.vim
+++ b/src/testdir/test_number.vim
@@ -298,6 +298,31 @@ func Test_relativenumber_colors()
call delete('XTest_relnr')
endfunc
+func Test_relativenumber_callback()
+ CheckScreendump
+ CheckFeature timers
+
+ let lines =<< trim END
+ call setline(1, ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'])
+ set relativenumber
+ call cursor(4, 1)
+
+ func Func(timer)
+ call cursor(1, 1)
+ endfunc
+
+ call timer_start(300, 'Func')
+ END
+ call writefile(lines, 'Xrnu_timer')
+
+ let buf = RunVimInTerminal('-S Xrnu_timer', #{rows: 8})
+ call TermWait(buf, 310)
+ call VerifyScreenDump(buf, 'Test_relativenumber_callback_1', {})
+
+ call StopVimInTerminal(buf)
+ call delete('Xrnu_timer')
+endfunc
+
" Test for displaying line numbers with 'rightleft'
func Test_number_rightleft()
CheckFeature rightleft
diff --git a/src/version.c b/src/version.c
index 4bcf0aec2..569d12c2b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4638,
+/**/
4637,
/**/
4636,