Skip to content

Commit

Permalink
change ellipsis token selection rendering to render as selected if th…
Browse files Browse the repository at this point in the history
…e selection overlaps its extent at all
  • Loading branch information
misson20000 committed Nov 24, 2024
1 parent ad788e4 commit 514e820
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/model/selection/listing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/view/listing/token_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 514e820

Please sign in to comment.