Fix root Windows virtual_path issues

This commit is contained in:
NotTheDr01ds 2024-09-25 10:29:44 -04:00
parent 4ef91e4a7a
commit a76cd758c1
5 changed files with 12 additions and 12 deletions

View File

@ -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);
}
}

View File

@ -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

View File

@ -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" [] {

View File

@ -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")
}

View File

@ -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
"#