From 37a499148ffda85a089042b4879fa0182c116f9f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 3 Jan 2019 00:09:35 +0100 Subject: Visual: highlight char-at-cursor Decide whether to highlight the visual-selected character under the cursor, depending on 'guicursor' style: - Highlight if cursor is blinking or non-block (vertical, horiz). - Do NOT highlight if cursor is non-blinking block. Traditionally Vim's visual selection does "reverse mode", which perhaps conflicts with the non-blinking block cursor. But 'guicursor' defaults to a vertical bar for selection=exclusive, and this confuses users who expect to see the text highlighted. closes #8983 --- src/nvim/cursor_shape.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nvim/cursor_shape.c') diff --git a/src/nvim/cursor_shape.c b/src/nvim/cursor_shape.c index cf79005a37..5551576c6d 100644 --- a/src/nvim/cursor_shape.c +++ b/src/nvim/cursor_shape.c @@ -254,6 +254,16 @@ char_u *parse_shape_opt(int what) return NULL; } +/// Returns true if the cursor is non-blinking "block" shape during +/// visual selection. +/// +/// @param exclusive If 'selection' option is "exclusive". +bool cursor_is_block_during_visual(bool exclusive) +{ + int mode_idx = exclusive ? SHAPE_IDX_VE : SHAPE_IDX_V; + return (SHAPE_BLOCK == shape_table[mode_idx].shape + && 0 == shape_table[mode_idx].blinkon); +} /// Map cursor mode from string to integer /// -- cgit