From de6251b207a81fe044d6e21b7f4bb799b87a7448 Mon Sep 17 00:00:00 2001 From: Tristam MacDonald Date: Fri, 26 Jan 2024 12:20:35 +0100 Subject: [PATCH] Activate the nushell virtualenv overlay correctly The activate.nu file works a little differently than it's counterparts in other shells, and it needs to be invoked as an overlay, rather than sourced directly into the shell. This fixes an outstanding issues left over from #6323. --- crates/project/src/terminals.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/project/src/terminals.rs b/crates/project/src/terminals.rs index 411a943aa4..0f314f5033 100644 --- a/crates/project/src/terminals.rs +++ b/crates/project/src/terminals.rs @@ -60,9 +60,11 @@ impl Project { .detach(); if let Some(python_settings) = &python_settings.as_option() { + let activate_command = Project::get_activate_command(python_settings); let activate_script_path = self.find_activate_script_path(python_settings, working_directory); self.activate_python_virtual_environment( + activate_command, activate_script_path, &terminal_handle, cx, @@ -104,15 +106,24 @@ impl Project { None } + fn get_activate_command(settings: &VenvSettingsContent) -> &'static str { + match settings.activate_script { + terminal_settings::ActivateScript::Nushell => "overlay use", + _ => "source", + } + } + fn activate_python_virtual_environment( &mut self, + activate_command: &'static str, activate_script: Option, terminal_handle: &Model, cx: &mut ModelContext, ) { if let Some(activate_script) = activate_script { // Paths are not strings so we need to jump through some hoops to format the command without `format!` - let mut command = Vec::from("source ".as_bytes()); + let mut command = Vec::from(activate_command.as_bytes()); + command.push(b' '); command.extend_from_slice(activate_script.as_os_str().as_bytes()); command.push(b'\n');