@@ -1194,7 +1194,7 @@ impl Project {
!self.is_local()
}
- pub fn create_terminal_connection(
+ pub fn create_terminal(
&mut self,
working_directory: Option<PathBuf>,
window_id: usize,
@@ -82,21 +82,22 @@ impl TerminalContainer {
let working_directory = get_working_directory(workspace, cx, strategy);
let window_id = cx.window_id();
+ let project = workspace.project().clone();
let terminal = workspace.project().update(cx, |project, cx| {
- project.create_terminal_connection(working_directory, window_id, cx)
+ project.create_terminal(working_directory, window_id, cx)
});
let view = cx.add_view(|cx| TerminalContainer::new(terminal, workspace.database_id(), cx));
workspace.add_item(Box::new(view), cx);
}
- ///Create a new Terminal view. This spawns a task, a thread, and opens the TTY devices
+ ///Create a new Terminal view.
pub fn new(
- model: anyhow::Result<ModelHandle<Terminal>>,
+ maybe_terminal: anyhow::Result<ModelHandle<Terminal>>,
workspace_id: WorkspaceId,
cx: &mut ViewContext<Self>,
) -> Self {
- let content = match model {
+ let content = match maybe_terminal {
Ok(terminal) => {
let item_id = cx.view_id();
let view = cx.add_view(|cx| {
@@ -251,8 +252,7 @@ impl Item for TerminalContainer {
//Directory of the terminal from outside the shell. There might be
//solutions to this, but they are non-trivial and require more IPC
Some(TerminalContainer::new(
- self.associated_directory.clone(),
- false,
+ Err(anyhow::anyhow!("failed to instantiate terminal")),
workspace_id,
cx,
))
@@ -354,12 +354,13 @@ impl Item for TerminalContainer {
}
fn deserialize(
- _project: ModelHandle<Project>,
+ project: ModelHandle<Project>,
_workspace: WeakViewHandle<Workspace>,
workspace_id: workspace::WorkspaceId,
item_id: workspace::ItemId,
cx: &mut ViewContext<Pane>,
) -> Task<anyhow::Result<ViewHandle<Self>>> {
+ let window_id = cx.window_id();
cx.spawn(|pane, mut cx| async move {
let cwd = TERMINAL_DB
.take_working_directory(item_id, workspace_id)
@@ -368,8 +369,12 @@ impl Item for TerminalContainer {
.flatten();
cx.update(|cx| {
+ let terminal = project.update(cx, |project, cx| {
+ project.create_terminal(cwd, window_id, cx)
+ });
+
Ok(cx.add_view(pane, |cx| {
- TerminalContainer::new(cwd, false, workspace_id, cx)
+ TerminalContainer::new(terminal, workspace_id, cx)
}))
})
})
@@ -32,7 +32,7 @@ use util::ResultExt;
use std::{fmt::Debug, ops::RangeInclusive};
use std::{mem, ops::Range};
-use crate::terminal_view::{DeployContextMenu, TerminalView};
+use crate::{DeployContextMenu, TerminalView};
///The information generated during layout that is nescessary for painting
pub struct LayoutState {
@@ -22,12 +22,12 @@ use terminal::{
index::Point,
term::{search::RegexSearch, TermMode},
},
- Terminal,
+ Event, Terminal,
};
use util::ResultExt;
use workspace::{pane, ItemId, WorkspaceId};
-use crate::{persistence::TERMINAL_DB, terminal_element::TerminalElement, Event};
+use crate::{persistence::TERMINAL_DB, terminal_element::TerminalElement};
const CURSOR_BLINK_INTERVAL: Duration = Duration::from_millis(500);
@@ -32,7 +32,7 @@ use settings::{
use smol::process::Command;
use std::fs::OpenOptions;
use std::{env, ffi::OsStr, panic, path::PathBuf, sync::Arc, thread, time::Duration};
-use terminal_view::{get_working_directory, TerminalContainer};
+use terminal_view::terminal_container_view::{get_working_directory, TerminalContainer};
use fs::RealFs;
use settings::watched_json::{watch_keymap_file, watch_settings_file, WatchedJsonFile};
@@ -595,7 +595,11 @@ pub fn default_item_factory(
let working_directory = get_working_directory(workspace, cx, strategy);
let terminal_handle = cx.add_view(|cx| {
- TerminalContainer::new(working_directory, false, workspace.database_id(), cx)
+ TerminalContainer::new(
+ Err(anyhow!("Don't have a project to open a terminal")),
+ workspace.database_id(),
+ cx,
+ )
});
Box::new(terminal_handle)
}