Compute view ancestry at layout time

This commit is contained in:
Antonio Scandurra 2023-05-03 16:36:14 +02:00
parent 7f345f8bf5
commit 7f137ed3dd
18 changed files with 246 additions and 225 deletions

View file

@ -2,7 +2,6 @@ mod persistence;
pub mod terminal_button;
pub mod terminal_element;
use anyhow::anyhow;
use context_menu::{ContextMenu, ContextMenuItem};
use dirs::home_dir;
use gpui::{
@ -628,16 +627,12 @@ impl Item for TerminalView {
})
});
let pane = pane
.upgrade(&cx)
.ok_or_else(|| anyhow!("pane was dropped"))?;
cx.update(|cx| {
let terminal = project.update(cx, |project, cx| {
project.create_terminal(cwd, window_id, cx)
})?;
Ok(cx.add_view(&pane, |cx| TerminalView::new(terminal, workspace_id, cx)))
})
let terminal = project.update(&mut cx, |project, cx| {
project.create_terminal(cwd, window_id, cx)
})?;
Ok(pane.update(&mut cx, |_, cx| {
cx.add_view(|cx| TerminalView::new(terminal, workspace_id, cx))
})?)
})
}