diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index e14991614a..56948bfd6e 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -22,8 +22,7 @@ use gpui::{ use items::BufferItemHandle; use language::{ multi_buffer::{ - Anchor, AnchorRangeExt, AnchorRangeSet, MultiBuffer, MultiBufferSnapshot, SelectionSet, - ToOffset, ToPoint, + Anchor, AnchorRangeExt, MultiBuffer, MultiBufferSnapshot, SelectionSet, ToOffset, ToPoint, }, BracketPair, Buffer, Diagnostic, DiagnosticSeverity, Language, Point, Selection, SelectionGoal, SelectionSetId, @@ -1292,19 +1291,19 @@ impl Editor { } fn autoclose_pairs(&mut self, cx: &mut ViewContext) { - let selections = self.selections::(cx).collect::>(); + let selections = self.selections::(cx); let new_autoclose_pair = self.buffer.update(cx, |buffer, cx| { let autoclose_pair = buffer.language().and_then(|language| { let first_selection_start = selections.first().unwrap().start; let pair = language.brackets().iter().find(|pair| { - buffer_snapshot.contains_str_at( + buffer.contains_str_at( first_selection_start.saturating_sub(pair.start.len()), &pair.start, ) }); pair.and_then(|pair| { let should_autoclose = selections[1..].iter().all(|selection| { - buffer_snapshot.contains_str_at( + buffer.contains_str_at( selection.start.saturating_sub(pair.start.len()), &pair.start, ) @@ -1322,7 +1321,7 @@ impl Editor { let selection_ranges = selections .iter() .map(|selection| { - let start = selection.start.to_offset(&buffer_snapshot); + let start = selection.start.to_offset(buffer); start..start }) .collect::>(); diff --git a/crates/language/src/multi_buffer.rs b/crates/language/src/multi_buffer.rs index 081f4ff8e1..8f8274a744 100644 --- a/crates/language/src/multi_buffer.rs +++ b/crates/language/src/multi_buffer.rs @@ -3,7 +3,7 @@ mod selection; use crate::{ buffer::{self, Buffer, Chunk, ToOffset as _, ToPoint as _}, - BufferSnapshot, Diagnostic, File, Language, + BufferSnapshot, Diagnostic, DiagnosticEntry, File, Language, }; pub use anchor::{Anchor, AnchorRangeExt}; use anyhow::Result; @@ -383,6 +383,13 @@ impl MultiBuffer { [].into_iter() } + pub fn contains_str_at(&self, _: T, _: &str) -> bool + where + T: ToOffset, + { + todo!() + } + pub fn max_point(&self) -> Point { self.snapshot.lock().max_point() } @@ -438,7 +445,7 @@ impl MultiBuffer { pub fn diagnostics_in_range<'a, T, O>( &'a self, search_range: Range, - ) -> impl Iterator, &Diagnostic)> + 'a + ) -> impl Iterator> + 'a where T: 'a + ToOffset, O: 'a,