text: Assert text anchor offset validity on construction (#38441)
Attempt to aid debugging some utf8 indexing issues Release Notes: - N/A Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
co-authored by
Mikayla Maki
parent
79620454d0
commit
a2c71d3d20
@@ -4121,8 +4121,7 @@ impl BufferSnapshot {
|
||||
range: Range<T>,
|
||||
) -> impl Iterator<Item = BracketMatch> + '_ {
|
||||
// Find bracket pairs that *inclusively* contain the given range.
|
||||
let range = range.start.to_offset(self).saturating_sub(1)
|
||||
..self.len().min(range.end.to_offset(self) + 1);
|
||||
let range = range.start.to_previous_offset(self)..range.end.to_next_offset(self);
|
||||
self.all_bracket_ranges(range)
|
||||
.filter(|pair| !pair.newline_only)
|
||||
}
|
||||
@@ -4131,8 +4130,7 @@ impl BufferSnapshot {
|
||||
&self,
|
||||
range: Range<T>,
|
||||
) -> impl Iterator<Item = (Range<usize>, DebuggerTextObject)> + '_ {
|
||||
let range = range.start.to_offset(self).saturating_sub(1)
|
||||
..self.len().min(range.end.to_offset(self) + 1);
|
||||
let range = range.start.to_previous_offset(self)..range.end.to_next_offset(self);
|
||||
|
||||
let mut matches = self.syntax.matches_with_options(
|
||||
range.clone(),
|
||||
|
||||
Reference in New Issue
Block a user