mirror of
https://github.com/nushell/nushell.git
synced 2025-08-12 16:37:09 +02:00
Call set_pwd_per_drive() within stack::set_cwd()
This commit is contained in:
@ -858,8 +858,6 @@ fn do_auto_cd(
|
|||||||
report_shell_error(engine_state, &err);
|
report_shell_error(engine_state, &err);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
// Let PWD-per-drive sync with auto_cd target
|
|
||||||
let _ = nu_path::set_pwd_per_drive(PathBuf::from(path.clone()).as_path());
|
|
||||||
let cwd = Value::string(cwd, span);
|
let cwd = Value::string(cwd, span);
|
||||||
|
|
||||||
let shells = stack.get_env_var(engine_state, "NUSHELL_SHELLS");
|
let shells = stack.get_env_var(engine_state, "NUSHELL_SHELLS");
|
||||||
|
@ -114,8 +114,6 @@ impl Command for Cd {
|
|||||||
//FIXME: this only changes the current scope, but instead this environment variable
|
//FIXME: this only changes the current scope, but instead this environment variable
|
||||||
//should probably be a block that loads the information from the state in the overlay
|
//should probably be a block that loads the information from the state in the overlay
|
||||||
PermissionResult::PermissionOk => {
|
PermissionResult::PermissionOk => {
|
||||||
// Let PWD-per-drive sync with cd target
|
|
||||||
let _ = nu_path::set_pwd_per_drive(path.as_path());
|
|
||||||
stack.set_cwd(path)?;
|
stack.set_cwd(path)?;
|
||||||
Ok(PipelineData::empty())
|
Ok(PipelineData::empty())
|
||||||
}
|
}
|
||||||
|
@ -280,8 +280,9 @@ pub mod pwd_per_drive_singleton {
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
/// set_pwd_per_drive
|
/// set_pwd_per_drive
|
||||||
/// record PWD for drive, path must be absolute path
|
/// On Windows, record PWD for drive, path must be absolute path
|
||||||
/// return Ok(()) if succeeded, otherwise error message
|
/// return Ok(()) if succeeded, otherwise error message
|
||||||
|
/// Other platforms, return Ok(())
|
||||||
pub fn set_pwd_per_drive(_path: &Path) -> Result<(), String> {
|
pub fn set_pwd_per_drive(_path: &Path) -> Result<(), String> {
|
||||||
cfg_if::cfg_if! { if #[cfg(target_os="windows")] {
|
cfg_if::cfg_if! { if #[cfg(target_os="windows")] {
|
||||||
|
|
||||||
@ -317,7 +318,7 @@ pub mod pwd_per_drive_singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cfg_if::cfg_if! { if #[cfg(target_os="windows")] {
|
cfg_if::cfg_if! { if #[cfg(target_os="windows")] {
|
||||||
/// Helper only used on windows, if input path is relative path
|
/// Helper only used on Windows, if input path is relative path
|
||||||
/// with drive letter, it can be expanded with PWD-per-drive.
|
/// with drive letter, it can be expanded with PWD-per-drive.
|
||||||
fn need_expand_pwd_per_drive(_path: &Path) -> bool {
|
fn need_expand_pwd_per_drive(_path: &Path) -> bool {
|
||||||
if let Some(path_str) = _path.to_str() {
|
if let Some(path_str) = _path.to_str() {
|
||||||
|
@ -726,6 +726,8 @@ impl Stack {
|
|||||||
let path = nu_path::strip_trailing_slash(path);
|
let path = nu_path::strip_trailing_slash(path);
|
||||||
let value = Value::string(path.to_string_lossy(), Span::unknown());
|
let value = Value::string(path.to_string_lossy(), Span::unknown());
|
||||||
self.add_env_var("PWD".into(), value);
|
self.add_env_var("PWD".into(), value);
|
||||||
|
// Sync with PWD-per-drive
|
||||||
|
let _ = nu_path::set_pwd_per_drive(&path);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ use log::{trace, Level};
|
|||||||
use miette::Result;
|
use miette::Result;
|
||||||
use nu_cli::gather_parent_env_vars;
|
use nu_cli::gather_parent_env_vars;
|
||||||
use nu_lsp::LanguageServer;
|
use nu_lsp::LanguageServer;
|
||||||
use nu_path::{canonicalize_with, set_pwd_per_drive};
|
use nu_path::canonicalize_with;
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
engine::EngineState, report_shell_error, ByteStream, PipelineData, ShellError, Span, Spanned,
|
engine::EngineState, report_shell_error, ByteStream, PipelineData, ShellError, Span, Spanned,
|
||||||
Value,
|
Value,
|
||||||
@ -78,8 +78,8 @@ fn main() -> Result<()> {
|
|||||||
|
|
||||||
// Get the current working directory from the environment.
|
// Get the current working directory from the environment.
|
||||||
let init_cwd = current_dir_from_environment();
|
let init_cwd = current_dir_from_environment();
|
||||||
// Let PWD-per-drive sync from startup
|
// Sync with PWD-per-drive
|
||||||
let _ = set_pwd_per_drive(init_cwd.as_ref());
|
let _ = nu_path::set_pwd_per_drive(init_cwd.as_ref());
|
||||||
|
|
||||||
// Custom additions
|
// Custom additions
|
||||||
let delta = {
|
let delta = {
|
||||||
|
Reference in New Issue
Block a user