Take local project settings into account when launching terminals (#11526)
LoganDark
created
Fixes #7599
Use project level settings if possible, when creating terminals.
Release Notes:
- Fixed terminals ignoring project-specific settings ([7599](https://github.com/zed-industries/zed/issues/7599))
Change summary
crates/project/src/terminals.rs | 21 +++++++++++++++++++--
crates/terminal_view/src/terminal_panel.rs | 1 +
2 files changed, 20 insertions(+), 2 deletions(-)
Detailed changes
@@ -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);
@@ -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| {