on master help sign in
highlight non-bar cursors (#5575)
7868e5fPascal Kuthe
helix-term/src/ui/editor.rs+18−2
@@ -392,7 +392,14 @@ impl EditorView {
392 if range.head > range.anchor {
392 if range.head > range.anchor {
393 // Standard case.
393 // Standard case.
394 let cursor_start = prev_grapheme_boundary(text, range.head);
394 let cursor_start = prev_grapheme_boundary(text, range.head);
395+ // non block cursors look like they exclude the cursor
396+ let selection_end =
397+ if selection_is_primary && !cursor_is_block && mode != Mode::Insert {
398+ range.head
399+ } else {
400+ cursor_start
401+ };
395− spans.push((selection_scope, range.anchor..cursor_start));
402+ spans.push((selection_scope, range.anchor..selection_end));
396 if !selection_is_primary || cursor_is_block {
403 if !selection_is_primary || cursor_is_block {
397 spans.push((cursor_scope, cursor_start..range.head));
404 spans.push((cursor_scope, cursor_start..range.head));
398 }
405 }
@@ -402,7 +409,16 @@ impl EditorView {
402 if !selection_is_primary || cursor_is_block {
409 if !selection_is_primary || cursor_is_block {
403 spans.push((cursor_scope, range.head..cursor_end));
410 spans.push((cursor_scope, range.head..cursor_end));
404 }
411 }
412+ // non block cursors look like they exclude the cursor
413+ let selection_start = if selection_is_primary
414+ && !cursor_is_block
415+ && !(mode == Mode::Insert && cursor_end == range.anchor)
416+ {
417+ range.head
418+ } else {
419+ cursor_end
420+ };
405− spans.push((selection_scope, cursor_end..range.anchor));
421+ spans.push((selection_scope, selection_start..range.anchor));
406 }
422 }
407 }
423 }
408
424