Skip to content

Commit

Permalink
Expand selections to start and end of the selected lines
Browse files Browse the repository at this point in the history
  • Loading branch information
kshokhin committed May 9, 2024
1 parent 31d615f commit 80503b7
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/editor/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,22 @@ impl SearchableItem for Editor {
}

if enabled {
let ranges = self.selections.disjoint_anchor_ranges();
let snapshot = &self.snapshot(cx).buffer_snapshot;
let ranges = self
.selections
.disjoint_anchor_ranges()
.into_iter()
.map(|range| {
let point_range = range.to_point(snapshot);
snapshot.anchor_before(Point {
row: point_range.start.row,
column: 0,
})..snapshot.anchor_after(Point {
row: point_range.end.row,
column: snapshot.line_len(point_range.end.row),
})
})
.collect::<Vec<_>>();
self.set_search_within_ranges(&ranges, cx);
}
}
Expand Down

0 comments on commit 80503b7

Please sign in to comment.