Activate the nushell virtualenv overlay correctly (#6766)
The activate.nu file works a little differently than its counterparts in other shells, and it needs to be invoked as an overlay, rather than sourced directly into the shell. This fixes an outstanding issue left over from #6323. Release Notes: - (Improved) ... ([#6323](https://github.com/zed-industries/zed/issues/6323)).
This commit is contained in:
commit
c9c9a6b11b
1 changed files with 12 additions and 1 deletions
|
@ -60,9 +60,11 @@ impl Project {
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
if let Some(python_settings) = &python_settings.as_option() {
|
if let Some(python_settings) = &python_settings.as_option() {
|
||||||
|
let activate_command = Project::get_activate_command(python_settings);
|
||||||
let activate_script_path =
|
let activate_script_path =
|
||||||
self.find_activate_script_path(python_settings, working_directory);
|
self.find_activate_script_path(python_settings, working_directory);
|
||||||
self.activate_python_virtual_environment(
|
self.activate_python_virtual_environment(
|
||||||
|
activate_command,
|
||||||
activate_script_path,
|
activate_script_path,
|
||||||
&terminal_handle,
|
&terminal_handle,
|
||||||
cx,
|
cx,
|
||||||
|
@ -104,15 +106,24 @@ impl Project {
|
||||||
None
|
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(
|
fn activate_python_virtual_environment(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
activate_command: &'static str,
|
||||||
activate_script: Option<PathBuf>,
|
activate_script: Option<PathBuf>,
|
||||||
terminal_handle: &Model<Terminal>,
|
terminal_handle: &Model<Terminal>,
|
||||||
cx: &mut ModelContext<Project>,
|
cx: &mut ModelContext<Project>,
|
||||||
) {
|
) {
|
||||||
if let Some(activate_script) = activate_script {
|
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!`
|
// 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.extend_from_slice(activate_script.as_os_str().as_bytes());
|
||||||
command.push(b'\n');
|
command.push(b'\n');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue