Use offset to restore navigation position if anchor can't be resolved

This commit is contained in:
Antonio Scandurra 2022-01-18 09:59:28 +01:00
parent d480738cc5
commit d5acbe1e32
4 changed files with 39 additions and 12 deletions

View file

@ -1131,12 +1131,6 @@ impl Buffer {
}
}
pub fn can_resolve(&self, anchor: &Anchor) -> bool {
*anchor == Anchor::min()
|| *anchor == Anchor::max()
|| self.version.observed(anchor.timestamp)
}
pub fn peek_undo_stack(&self) -> Option<&Transaction> {
self.history.undo_stack.last()
}
@ -1648,6 +1642,12 @@ impl BufferSnapshot {
}
}
pub fn can_resolve(&self, anchor: &Anchor) -> bool {
*anchor == Anchor::min()
|| *anchor == Anchor::max()
|| self.version.observed(anchor.timestamp)
}
pub fn clip_offset(&self, offset: usize, bias: Bias) -> usize {
self.visible_text.clip_offset(offset, bias)
}