Skip to content

Commit

Permalink
Enable toolchain venv in terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
sn1c committed Dec 1, 2024
1 parent 4d54152 commit 88954e9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/project/src/terminals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use anyhow::Context as _;
use collections::HashMap;
use gpui::{AnyWindowHandle, AppContext, Context, Entity, Model, ModelContext, WeakModel};
use itertools::Itertools;
use language::LanguageName;
use settings::{Settings, SettingsLocation};
use smol::channel::bounded;
use std::{
Expand Down Expand Up @@ -128,6 +129,7 @@ impl Project {
} else {
None
};

let python_venv_directory = path
.as_ref()
.and_then(|path| self.python_venv_directory(path, settings, cx));
Expand Down Expand Up @@ -277,6 +279,20 @@ impl Project {
settings: &TerminalSettings,
cx: &AppContext,
) -> Option<PathBuf> {
if let Some((worktree, _)) = self.find_worktree(abs_path, cx) {
let toolchain = self
.active_toolchain(worktree.read(cx).id(), LanguageName::new("Python"), cx)
.now_or_never()
.unwrap();

if let Some(toolchain) = toolchain {
let mut path = PathBuf::from(String::from(toolchain.path));
path.pop();
path.pop();
return Some(path);
}
}

let venv_settings = settings.detect_venv.as_option()?;
if let Some(path) = self.find_venv_in_worktree(abs_path, &venv_settings, cx) {
return Some(path);
Expand Down

0 comments on commit 88954e9

Please sign in to comment.