From a76cd758c1878d6a77947af08a1001452bf9eceb Mon Sep 17 00:00:00 2001 From: NotTheDr01ds <32344964+NotTheDr01ds@users.noreply.github.com> Date: Wed, 25 Sep 2024 10:29:44 -0400 Subject: [PATCH] Fix root Windows virtual_path issues --- crates/nu-protocol/src/engine/state_working_set.rs | 7 +++++-- crates/nu-std/src/lib.rs | 4 ++-- crates/nu-std/testing.nu | 4 ++-- tests/repl/test_stdlib.rs | 5 +---- tests/shell/environment/env.rs | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/nu-protocol/src/engine/state_working_set.rs b/crates/nu-protocol/src/engine/state_working_set.rs index eb60f9df8b..387f591ac6 100644 --- a/crates/nu-protocol/src/engine/state_working_set.rs +++ b/crates/nu-protocol/src/engine/state_working_set.rs @@ -1003,14 +1003,17 @@ impl<'a> StateWorkingSet<'a> { } pub fn find_virtual_path(&self, name: &str) -> Option<&VirtualPath> { + // Platform appropriate virtual path (slashes or backslashes) + let virtual_path_name = Path::new(name); + for (virtual_name, virtual_path) in self.delta.virtual_paths.iter().rev() { - if virtual_name == name { + if Path::new(virtual_name) == virtual_path_name { return Some(virtual_path); } } for (virtual_name, virtual_path) in self.permanent_state.virtual_paths.iter().rev() { - if virtual_name == name { + if Path::new(virtual_name) == virtual_path_name { return Some(virtual_path); } } diff --git a/crates/nu-std/src/lib.rs b/crates/nu-std/src/lib.rs index 340727d2ee..361c0cd510 100644 --- a/crates/nu-std/src/lib.rs +++ b/crates/nu-std/src/lib.rs @@ -52,8 +52,8 @@ pub fn load_standard_library( let std_dir = std_dir.to_string_lossy().to_string(); let source = r#" # Prelude -use ([ std core ] | path join) * -use ([ std deprecated_dirs] | path join) [ +use std/core * +use std/deprecated_dirs [ enter shells g diff --git a/crates/nu-std/testing.nu b/crates/nu-std/testing.nu index 3bdb9956dc..003e1d1ebc 100644 --- a/crates/nu-std/testing.nu +++ b/crates/nu-std/testing.nu @@ -1,7 +1,7 @@ -use (['std', 'log'] | path join) +use std/log export-env { # Place NU_FORMAT... environment variables in module-scope - export use (['std', 'log'] | path join) * + export use std/log * } def "nu-complete threads" [] { diff --git a/tests/repl/test_stdlib.rs b/tests/repl/test_stdlib.rs index 51772f09fe..b15a10dd22 100644 --- a/tests/repl/test_stdlib.rs +++ b/tests/repl/test_stdlib.rs @@ -7,8 +7,5 @@ fn not_loaded() -> TestResult { #[test] fn use_command() -> TestResult { - run_test_std( - "use ([ std, assert ] | path join); assert true; print 'it works'", - "it works", - ) + run_test_std("use std/assert; assert true; print 'it works'", "it works") } diff --git a/tests/shell/environment/env.rs b/tests/shell/environment/env.rs index a78f4594b5..35692fdee9 100644 --- a/tests/shell/environment/env.rs +++ b/tests/shell/environment/env.rs @@ -224,7 +224,7 @@ fn std_log_env_vars_are_not_overridden() { ("NU_LOG_DATE_FORMAT".to_string(), "%Y".to_string()), ], r#" - use ([ std, log] | path join) + use std/log print -e $env.NU_LOG_FORMAT print -e $env.NU_LOG_DATE_FORMAT log error "err" @@ -237,7 +237,7 @@ fn std_log_env_vars_are_not_overridden() { fn std_log_env_vars_have_defaults() { let actual = nu_with_std!( r#" - use ([ std, log] | path join) + use std/log print -e $env.NU_LOG_FORMAT print -e $env.NU_LOG_DATE_FORMAT "#