From 514e8200c6f49e45ebc05ca20ea036caa40dc2d2 Mon Sep 17 00:00:00 2001 From: misson20000 Date: Sat, 23 Nov 2024 23:17:12 -0500 Subject: [PATCH] change ellipsis token selection rendering to render as selected if the selection overlaps its extent at all --- src/model/selection/listing.rs | 8 ++++++++ src/view/listing/token_view.rs | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/model/selection/listing.rs b/src/model/selection/listing.rs index 28bfa07..424855b 100644 --- a/src/model/selection/listing.rs +++ b/src/model/selection/listing.rs @@ -456,6 +456,14 @@ impl NodeIntersection { } } + pub fn overlaps(&self, extent: addr::Extent) -> bool { + match self { + Self::None => false, + Self::Partial(e, _, _) => e.intersection(extent).is_some(), + Self::Total => true, + } + } + pub fn includes_child(&self, index: usize) -> bool { match self { Self::None => false, diff --git a/src/view/listing/token_view.rs b/src/view/listing/token_view.rs index 1e749ac..7a091f3 100644 --- a/src/view/listing/token_view.rs +++ b/src/view/listing/token_view.rs @@ -174,8 +174,7 @@ impl TokenView { .render(snapshot); }, token::Token::Ellipsis(token) => { - let index = token.node_child_index(); - let selected = (index == 0 || selection.includes_child(index-1)) && selection.includes_child(index); + let selected = selection.overlaps(token.extent); render.gsc_mono.begin(gsc::Entry::Ellipsis, render.config.text_color.rgba(), &mut pos) .cursor(has_cursor, cursor, render.config.cursor_fg_color.rgba(), render.config.cursor_bg_color.rgba())