Use Project
's EntityId as the "window id" for Alacritty PTYs (#35876)
It's unfortunate to need to have access to a GPUI window in order to create a terminal, because it forces to take a `Window` parameter in entities that otherwise would have been pure models. This pull request changes it so that we pass the `Project`'s entity id, which is equally stable as the window id. Release Notes: - N/A Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
This commit is contained in:
parent
95547f099c
commit
51298b6912
7 changed files with 17 additions and 39 deletions
|
@ -245,9 +245,8 @@ async fn deserialize_pane_group(
|
|||
let kind = TerminalKind::Shell(
|
||||
working_directory.as_deref().map(Path::to_path_buf),
|
||||
);
|
||||
let window = window.window_handle();
|
||||
let terminal = project
|
||||
.update(cx, |project, cx| project.create_terminal(kind, window, cx));
|
||||
let terminal =
|
||||
project.update(cx, |project, cx| project.create_terminal(kind, cx));
|
||||
Some(Some(terminal))
|
||||
} else {
|
||||
Some(None)
|
||||
|
|
|
@ -432,10 +432,9 @@ impl TerminalPanel {
|
|||
})
|
||||
.unwrap_or((None, None));
|
||||
let kind = TerminalKind::Shell(working_directory);
|
||||
let window_handle = window.window_handle();
|
||||
let terminal = project
|
||||
.update(cx, |project, cx| {
|
||||
project.create_terminal_with_venv(kind, python_venv_directory, window_handle, cx)
|
||||
project.create_terminal_with_venv(kind, python_venv_directory, cx)
|
||||
})
|
||||
.ok()?;
|
||||
|
||||
|
@ -666,13 +665,10 @@ impl TerminalPanel {
|
|||
"terminal not yet supported for remote projects"
|
||||
)));
|
||||
}
|
||||
let window_handle = window.window_handle();
|
||||
let project = workspace.project().downgrade();
|
||||
cx.spawn_in(window, async move |workspace, cx| {
|
||||
let terminal = project
|
||||
.update(cx, |project, cx| {
|
||||
project.create_terminal(kind, window_handle, cx)
|
||||
})?
|
||||
.update(cx, |project, cx| project.create_terminal(kind, cx))?
|
||||
.await?;
|
||||
|
||||
workspace.update_in(cx, |workspace, window, cx| {
|
||||
|
@ -709,11 +705,8 @@ impl TerminalPanel {
|
|||
terminal_panel.active_pane.clone()
|
||||
})?;
|
||||
let project = workspace.read_with(cx, |workspace, _| workspace.project().clone())?;
|
||||
let window_handle = cx.window_handle();
|
||||
let terminal = project
|
||||
.update(cx, |project, cx| {
|
||||
project.create_terminal(kind, window_handle, cx)
|
||||
})?
|
||||
.update(cx, |project, cx| project.create_terminal(kind, cx))?
|
||||
.await?;
|
||||
let result = workspace.update_in(cx, |workspace, window, cx| {
|
||||
let terminal_view = Box::new(cx.new(|cx| {
|
||||
|
@ -814,7 +807,6 @@ impl TerminalPanel {
|
|||
) -> Task<Result<WeakEntity<Terminal>>> {
|
||||
let reveal = spawn_task.reveal;
|
||||
let reveal_target = spawn_task.reveal_target;
|
||||
let window_handle = window.window_handle();
|
||||
let task_workspace = self.workspace.clone();
|
||||
cx.spawn_in(window, async move |terminal_panel, cx| {
|
||||
let project = terminal_panel.update(cx, |this, cx| {
|
||||
|
@ -823,7 +815,7 @@ impl TerminalPanel {
|
|||
})??;
|
||||
let new_terminal = project
|
||||
.update(cx, |project, cx| {
|
||||
project.create_terminal(TerminalKind::Task(spawn_task), window_handle, cx)
|
||||
project.create_terminal(TerminalKind::Task(spawn_task), cx)
|
||||
})?
|
||||
.await?;
|
||||
terminal_to_replace.update_in(cx, |terminal_to_replace, window, cx| {
|
||||
|
|
|
@ -1654,7 +1654,6 @@ impl Item for TerminalView {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Option<Entity<Self>> {
|
||||
let window_handle = window.window_handle();
|
||||
let terminal = self
|
||||
.project
|
||||
.update(cx, |project, cx| {
|
||||
|
@ -1666,7 +1665,6 @@ impl Item for TerminalView {
|
|||
project.create_terminal_with_venv(
|
||||
TerminalKind::Shell(working_directory),
|
||||
python_venv_directory,
|
||||
window_handle,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
|
@ -1802,7 +1800,6 @@ impl SerializableItem for TerminalView {
|
|||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> Task<anyhow::Result<Entity<Self>>> {
|
||||
let window_handle = window.window_handle();
|
||||
window.spawn(cx, async move |cx| {
|
||||
let cwd = cx
|
||||
.update(|_window, cx| {
|
||||
|
@ -1826,7 +1823,7 @@ impl SerializableItem for TerminalView {
|
|||
|
||||
let terminal = project
|
||||
.update(cx, |project, cx| {
|
||||
project.create_terminal(TerminalKind::Shell(cwd), window_handle, cx)
|
||||
project.create_terminal(TerminalKind::Shell(cwd), cx)
|
||||
})?
|
||||
.await?;
|
||||
cx.update(|window, cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue