aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/screen.c
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2019-01-13 12:10:26 +0100
committerGitHub <noreply@github.com>2019-01-13 12:10:26 +0100
commita7fc01a532e753e2f5a7d0f2b8f670144d78a878 (patch)
tree36060b7fdfb919a7f36faf0dad9790a95088c0e7 /src/nvim/screen.c
parent424388c207eaf6b5f564ff8247b5800ab337bc56 (diff)
parent23c71d5182a5e717c3a1852d9d3c90e81b4735fd (diff)
downloadrneovim-a7fc01a532e753e2f5a7d0f2b8f670144d78a878.tar.gz
rneovim-a7fc01a532e753e2f5a7d0f2b8f670144d78a878.tar.bz2
rneovim-a7fc01a532e753e2f5a7d0f2b8f670144d78a878.zip
Merge pull request #9492 from bfredl/cul_cole
redraw: share more code between cursorline and conceal redraws. Add tests for conceal cursor
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;