Use the new split pane's navigation history when cloning an item

This commit is contained in:
Antonio Scandurra
2022-02-25 17:22:30 +01:00
parent 88bfe5acb0
commit b506db7c93
6 changed files with 67 additions and 34 deletions
+2 -5
View File
@@ -834,7 +834,7 @@ impl Editor {
Self::new(EditorMode::Full, buffer, project, settings, None, cx)
}
pub fn clone(&self, cx: &mut ViewContext<Self>) -> Self {
pub fn clone(&self, nav_history: ItemNavHistory, cx: &mut ViewContext<Self>) -> Self {
let mut clone = Self::new(
self.mode,
self.buffer.clone(),
@@ -845,10 +845,7 @@ impl Editor {
);
clone.scroll_position = self.scroll_position;
clone.scroll_top_anchor = self.scroll_top_anchor.clone();
clone.nav_history = self
.nav_history
.as_ref()
.map(|nav_history| ItemNavHistory::new(nav_history.history(), &cx.handle()));
clone.nav_history = Some(nav_history);
clone
}
+6 -2
View File
@@ -194,11 +194,15 @@ impl ItemView for Editor {
})
}
fn clone_on_split(&self, cx: &mut ViewContext<Self>) -> Option<Self>
fn clone_on_split(
&self,
nav_history: ItemNavHistory,
cx: &mut ViewContext<Self>,
) -> Option<Self>
where
Self: Sized,
{
Some(self.clone(cx))
Some(self.clone(nav_history, cx))
}
fn deactivated(&mut self, cx: &mut ViewContext<Self>) {