Visual line mode handles soft wraps

This commit is contained in:
Keith Simmons 2022-05-23 09:23:25 -07:00
parent 33940b5dd9
commit 61f0daa5c5
14 changed files with 314 additions and 96 deletions

View file

@ -128,6 +128,20 @@ impl SelectionsCollection {
.collect()
}
// Returns all of the selections, adjusted to take into account the selection line_mode
pub fn all_adjusted(&self, cx: &mut MutableAppContext) -> Vec<Selection<Point>> {
let mut selections = self.all::<Point>(cx);
if self.line_mode {
let map = self.display_map(cx);
for selection in &mut selections {
let new_range = map.expand_to_line(selection.range());
selection.start = new_range.start;
selection.end = new_range.end;
}
}
selections
}
pub fn disjoint_in_range<'a, D>(
&self,
range: Range<Anchor>,