Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Take local project settings into account when launching terminals (#11526)

LoganDark45aca348b8e5
diff --git a/crates/project/src/terminals.rs b/crates/project/src/terminals.rs
index 4d1829dd429..fd18130031e 100644
--- a/crates/project/src/terminals.rs
+++ b/crates/project/src/terminals.rs
@@ -1,7 +1,7 @@
use crate::Project;
use collections::HashMap;
use gpui::{AnyWindowHandle, Context, Entity, Model, ModelContext, WeakModel};
-use settings::Settings;
+use settings::{Settings, SettingsLocation};
use smol::channel::bounded;
use std::path::{Path, PathBuf};
use task::SpawnInTerminal;
@@ -31,8 +31,25 @@ impl Project {
"creating terminals as a guest is not supported yet"
);
+ // used only for TerminalSettings::get
+ let worktree = {
+ let terminal_cwd = working_directory.as_deref();
+ let task_cwd = spawn_task
+ .as_ref()
+ .and_then(|spawn_task| spawn_task.cwd.as_deref());
+
+ terminal_cwd
+ .and_then(|terminal_cwd| self.find_local_worktree(terminal_cwd, cx))
+ .or_else(|| task_cwd.and_then(|spawn_cwd| self.find_local_worktree(spawn_cwd, cx)))
+ };
+
+ let settings_location = worktree.as_ref().map(|(worktree, path)| SettingsLocation {
+ worktree_id: worktree.read(cx).id().to_usize(),
+ path,
+ });
+
let is_terminal = spawn_task.is_none();
- let settings = TerminalSettings::get_global(cx);
+ let settings = TerminalSettings::get(settings_location, cx);
let python_settings = settings.detect_venv.clone();
let (completion_tx, completion_rx) = bounded(1);
diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs
index 89169f0233d..df7927a3c4a 100644
--- a/crates/terminal_view/src/terminal_panel.rs
+++ b/crates/terminal_view/src/terminal_panel.rs
@@ -596,6 +596,7 @@ impl TerminalPanel {
.workspace
.update(cx, |workspace, _| workspace.project().clone())
.ok()?;
+
let reveal = spawn_task.reveal;
let window = cx.window_handle();
let new_terminal = project.update(cx, |project, cx| {