aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/editor.rs
diff options
context:
space:
mode:
authorPascal Kuthe2023-01-18 16:28:45 +0000
committerGitHub2023-01-18 16:28:45 +0000
commit7868e5f2d8ab193431e45b8bb3cd048e766328c4 (patch)
tree3d016ecaa504bff53b83165447d4006babd1b554 /helix-term/src/ui/editor.rs
parent1b69c7b4af8867f46365f6e04ab2ba29676c312c (diff)
highlight non-bar cursors (#5575)
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r--helix-term/src/ui/editor.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index a19eb213..f8244600 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -392,7 +392,14 @@ impl EditorView {
if range.head > range.anchor {
// Standard case.
let cursor_start = prev_grapheme_boundary(text, range.head);
- spans.push((selection_scope, range.anchor..cursor_start));
+ // non block cursors look like they exclude the cursor
+ let selection_end =
+ if selection_is_primary && !cursor_is_block && mode != Mode::Insert {
+ range.head
+ } else {
+ cursor_start
+ };
+ spans.push((selection_scope, range.anchor..selection_end));
if !selection_is_primary || cursor_is_block {
spans.push((cursor_scope, cursor_start..range.head));
}
@@ -402,7 +409,16 @@ impl EditorView {
if !selection_is_primary || cursor_is_block {
spans.push((cursor_scope, range.head..cursor_end));
}
- spans.push((selection_scope, cursor_end..range.anchor));
+ // non block cursors look like they exclude the cursor
+ let selection_start = if selection_is_primary
+ && !cursor_is_block
+ && !(mode == Mode::Insert && cursor_end == range.anchor)
+ {
+ range.head
+ } else {
+ cursor_end
+ };
+ spans.push((selection_scope, selection_start..range.anchor));
}
}