aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/screen.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/screen.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/screen.c')
-rw-r--r--src/nvim/screen.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 68d95decff..a3f1f00db2 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -151,6 +151,8 @@ static bool send_grid_resize = false;
/// Highlight ids are no longer valid. Force retransmission
static bool highlights_invalid = false;
+static bool conceal_cursor_used = false;
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "screen.c.generated.h"
#endif
@@ -505,19 +507,28 @@ int conceal_cursor_line(win_T *wp)
return vim_strchr(wp->w_p_cocu, c) != NULL;
}
-/*
- * Check if the cursor line needs to be redrawn because of 'concealcursor'.
- */
+// Check if the cursor line needs to be redrawn because of 'concealcursor'.
+//
+// When cursor is moved at the same time, both lines will be redrawn regardless.
void conceal_check_cursor_line(void)
{
- if (curwin->w_p_cole > 0 && conceal_cursor_line(curwin)) {
- need_cursor_line_redraw = TRUE;
- /* Need to recompute cursor column, e.g., when starting Visual mode
- * without concealing. */
- curs_columns(TRUE);
+ bool should_conceal = conceal_cursor_line(curwin);
+ if (curwin->w_p_cole > 0 && (conceal_cursor_used != should_conceal)) {
+ redrawWinline(curwin, curwin->w_cursor.lnum);
+ // Need to recompute cursor column, e.g., when starting Visual mode
+ // without concealing. */
+ curs_columns(true);
}
}
+/// Whether cursorline is drawn in a special way
+///
+/// If true, both old and new cursorline will need
+/// need to be redrawn when moving cursor within windows.
+bool win_cursorline_standout(win_T *wp)
+{
+ return wp->w_p_cul || (wp->w_p_cole > 0 && !conceal_cursor_line(wp));
+}
/*
* Update a single window.
@@ -1942,6 +1953,7 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
curwin->w_cline_height = 1;
curwin->w_cline_folded = true;
curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW);
+ conceal_cursor_used = conceal_cursor_line(curwin);
}
}
@@ -3960,6 +3972,7 @@ win_line (
curwin->w_cline_height = row - startrow;
curwin->w_cline_folded = false;
curwin->w_valid |= (VALID_CHEIGHT|VALID_CROW);
+ conceal_cursor_used = conceal_cursor_line(curwin);
}
break;