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

View file

@ -598,7 +598,11 @@ impl workspace::ItemView for ProjectDiagnosticsEditor {
matches!(event, Event::Saved | Event::Dirtied | Event::TitleChanged)
}
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,
{
@ -608,13 +612,8 @@ impl workspace::ItemView for ProjectDiagnosticsEditor {
self.settings.clone(),
cx,
);
diagnostics.editor.update(cx, |editor, cx| {
let nav_history = self
.editor
.read(cx)
.nav_history()
.map(|nav_history| ItemNavHistory::new(nav_history.history(), &cx.handle()));
editor.set_nav_history(nav_history);
diagnostics.editor.update(cx, |editor, _| {
editor.set_nav_history(Some(nav_history));
});
Some(diagnostics)
}