WIP: Start on a GoToDefinition action for the editor

This commit is contained in:
Antonio Scandurra 2022-01-20 12:26:04 +01:00
parent cbbf7391e8
commit 66734e11af
2 changed files with 57 additions and 2 deletions

View file

@ -789,6 +789,19 @@ impl MultiBuffer {
cx.notify();
}
pub fn text_anchor_for_position<'a, T: ToOffset>(
&'a self,
position: T,
cx: &AppContext,
) -> (ModelHandle<Buffer>, language::Anchor) {
let snapshot = self.read(cx);
let anchor = snapshot.anchor_before(position);
(
self.buffers.borrow()[&anchor.buffer_id].buffer.clone(),
anchor.text_anchor,
)
}
fn on_buffer_event(
&mut self,
_: ModelHandle<Buffer>,