rename NavigationData anchor and offset to cursor_anchor and cursor_offset
This commit is contained in:
parent
9cec6d8d65
commit
b893cb6d82
2 changed files with 7 additions and 7 deletions
|
@ -850,8 +850,8 @@ struct ClipboardSelection {
|
||||||
pub struct NavigationData {
|
pub struct NavigationData {
|
||||||
// Matching offsets for anchor and scroll_top_anchor allows us to recreate the anchor if the buffer
|
// Matching offsets for anchor and scroll_top_anchor allows us to recreate the anchor if the buffer
|
||||||
// has since been closed
|
// has since been closed
|
||||||
anchor: Anchor,
|
cursor_anchor: Anchor,
|
||||||
offset: usize,
|
cursor_offset: usize,
|
||||||
scroll_position: Vector2F,
|
scroll_position: Vector2F,
|
||||||
scroll_top_anchor: Anchor,
|
scroll_top_anchor: Anchor,
|
||||||
scroll_top_offset: usize,
|
scroll_top_offset: usize,
|
||||||
|
@ -3912,8 +3912,8 @@ impl Editor {
|
||||||
}
|
}
|
||||||
|
|
||||||
nav_history.push(Some(NavigationData {
|
nav_history.push(Some(NavigationData {
|
||||||
anchor: position,
|
cursor_anchor: position,
|
||||||
offset,
|
cursor_offset: offset,
|
||||||
scroll_position: self.scroll_position,
|
scroll_position: self.scroll_position,
|
||||||
scroll_top_anchor: self.scroll_top_anchor.clone(),
|
scroll_top_anchor: self.scroll_top_anchor.clone(),
|
||||||
scroll_top_offset,
|
scroll_top_offset,
|
||||||
|
|
|
@ -247,10 +247,10 @@ impl Item for Editor {
|
||||||
fn navigate(&mut self, data: Box<dyn std::any::Any>, cx: &mut ViewContext<Self>) -> bool {
|
fn navigate(&mut self, data: Box<dyn std::any::Any>, cx: &mut ViewContext<Self>) -> bool {
|
||||||
if let Some(data) = data.downcast_ref::<NavigationData>() {
|
if let Some(data) = data.downcast_ref::<NavigationData>() {
|
||||||
let buffer = self.buffer.read(cx).read(cx);
|
let buffer = self.buffer.read(cx).read(cx);
|
||||||
let offset = if buffer.can_resolve(&data.anchor) {
|
let offset = if buffer.can_resolve(&data.cursor_anchor) {
|
||||||
data.anchor.to_offset(&buffer)
|
data.cursor_anchor.to_offset(&buffer)
|
||||||
} else {
|
} else {
|
||||||
buffer.clip_offset(data.offset, Bias::Left)
|
buffer.clip_offset(data.cursor_offset, Bias::Left)
|
||||||
};
|
};
|
||||||
let newest_selection = self.newest_selection_with_snapshot::<usize>(&buffer);
|
let newest_selection = self.newest_selection_with_snapshot::<usize>(&buffer);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue