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

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))
This commit is contained in:
LoganDark 2024-05-08 03:39:47 -07:00 committed by GitHub
parent 07942bbdfe
commit 45aca348b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 2 deletions

View File

@ -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);

View File

@ -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| {