Do not enable venv in terminal for bash-like oneshot task invocations (#8444)

Release Notes:
- Work around #8334 by only activating venv in the terminal not in tasks
(see #8440 for a proper solution)
- To use venv modify your tasks in the following way:
```json
{
  "label": "Python main.py",
  "command": "sh",
  "args": ["-c", "source .venv/bin/activate && python3 main.py"]
}
```

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
Stanislav Alekseev 2024-03-21 19:40:33 +02:00 committed by GitHub
parent cd61297740
commit 85fdcef564
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 109 additions and 49 deletions

View file

@ -15,7 +15,7 @@ doctest = false
[dependencies]
# TODO: when new version of this crate is released, change it
alacritty_terminal = { git = "https://github.com/alacritty/alacritty", rev = "992011a4cd9a35f197acc0a0bd430d89a0d01013" }
alacritty_terminal = "0.23.0-rc1"
anyhow.workspace = true
collections.workspace = true
dirs = "4.0.0"

View file

@ -310,13 +310,19 @@ impl TerminalBuilder {
working_directory: Option<PathBuf>,
task: Option<TaskState>,
shell: Shell,
env: HashMap<String, String>,
mut env: HashMap<String, String>,
blink_settings: Option<TerminalBlink>,
alternate_scroll: AlternateScroll,
max_scroll_history_lines: Option<usize>,
window: AnyWindowHandle,
completion_tx: Sender<()>,
) -> Result<TerminalBuilder> {
// TODO: Properly set the current locale,
env.entry("LC_ALL".to_string())
.or_insert_with(|| "en_US.UTF-8".to_string());
env.insert("ZED_TERM".to_string(), "true".to_string());
let pty_options = {
let alac_shell = match shell.clone() {
Shell::System => None,
@ -332,20 +338,13 @@ impl TerminalBuilder {
shell: alac_shell,
working_directory: working_directory.clone(),
hold: false,
env: env.into_iter().collect(),
}
};
// First, setup Alacritty's env
// Setup Alacritty's env
setup_env();
// Then setup configured environment variables
for (key, value) in env {
std::env::set_var(key, value);
}
//TODO: Properly set the current locale,
std::env::set_var("LC_ALL", "en_US.UTF-8");
std::env::set_var("ZED_TERM", "true");
let scrolling_history = if task.is_some() {
// Tasks like `cargo build --all` may produce a lot of output, ergo allow maximum scrolling.
// After the task finishes, we do not allow appending to that terminal, so small tasks output should not
@ -650,6 +649,9 @@ impl Terminal {
self.events
.push_back(InternalEvent::ColorRequest(*idx, fun_ptr.clone()));
}
AlacTermEvent::ChildExit(_) => {
// TODO: Handle child exit
}
}
}