aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-12 11:05:49 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2019-01-13 12:08:11 +0100
commit23c71d5182a5e717c3a1852d9d3c90e81b4735fd (patch)
treee6966f2a6cf3d2f3e230cfb95b2a84880a9975b6 /src/nvim/edit.c
parent9c75929e7b376a6f57246a954d2e0c5f3a1bc655 (diff)
downloadrneovim-23c71d5182a5e717c3a1852d9d3c90e81b4735fd.tar.gz
rneovim-23c71d5182a5e717c3a1852d9d3c90e81b4735fd.tar.bz2
rneovim-23c71d5182a5e717c3a1852d9d3c90e81b4735fd.zip
display: unify cursorline and concealcursor redraw logic
There is various places where 'conceallevel' and 'concealcursor' necessitates additional redraws. This tries to separate the different cases and handle each accordingly: - Share code with 'cursorline' for the common case: vertical move of cursor within the same window (concealcursor not active) - Improve the logic for managing 'concealcursor' and switching modes: test for the case where the new mode behaves differently from the last one. - Clarify the special case for horizontal movement within a line when 'concealcursor' is active, now there is an if-statement only for this and not hidden in larger check mostly for the first point. - Keep the special case for moving between windows as is.
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 257a6ef112..bb3c0ec196 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -306,10 +306,6 @@ static void insert_enter(InsertState *s)
}
}
- // Check if the cursor line needs redrawing before changing State. If
- // 'concealcursor' is "n" it needs to be redrawn without concealing.
- conceal_check_cursor_line();
-
// When doing a paste with the middle mouse button, Insstart is set to
// where the paste started.
if (where_paste_started.lnum != 0) {
@@ -1381,9 +1377,7 @@ ins_redraw (
int ready /* not busy with something */
)
{
- linenr_T conceal_old_cursor_line = 0;
- linenr_T conceal_new_cursor_line = 0;
- int conceal_update_lines = FALSE;
+ bool conceal_cursor_moved = false;
if (char_avail())
return;
@@ -1406,11 +1400,7 @@ ins_redraw (
update_curswant();
ins_apply_autocmds(EVENT_CURSORMOVEDI);
}
- if (curwin->w_p_cole > 0) {
- conceal_old_cursor_line = last_cursormoved.lnum;
- conceal_new_cursor_line = curwin->w_cursor.lnum;
- conceal_update_lines = TRUE;
- }
+ conceal_cursor_moved = true;
last_cursormoved = curwin->w_cursor;
}
@@ -1452,17 +1442,9 @@ ins_redraw (
}
}
- if ((conceal_update_lines
- && (conceal_old_cursor_line != conceal_new_cursor_line
- || conceal_cursor_line(curwin)))
- || need_cursor_line_redraw) {
- if (conceal_old_cursor_line != conceal_new_cursor_line) {
- redrawWinline(curwin, conceal_old_cursor_line);
- }
- redrawWinline(curwin, conceal_new_cursor_line == 0
- ? curwin->w_cursor.lnum : conceal_new_cursor_line);
- curwin->w_valid &= ~VALID_CROW;
- need_cursor_line_redraw = false;
+ if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin)
+ && conceal_cursor_moved) {
+ redrawWinline(curwin, curwin->w_cursor.lnum);
}
if (must_redraw) {