fix(completion): dotnu_completion dir with space, expand tilde (#14983)

# Description

This PR closes #14956, only one known issue on that list remains.

# User-Facing Changes
# Tests + Formatting
new cases added
# After Submitting
This commit is contained in:
zc he
2025-02-02 21:54:09 +08:00
committed by GitHub
parent 63fa6a6df7
commit 5291f978c2
3 changed files with 52 additions and 20 deletions

View File

@ -275,12 +275,30 @@ fn dotnu_completions() {
// Test nested nu script
#[cfg(windows)]
let completion_str = "use .\\dir_module\\sub_module\\".to_string();
let completion_str = "use `.\\dir_module\\".to_string();
#[cfg(not(windows))]
let completion_str = "use ./dir_module/sub_module/".to_string();
let completion_str = "use `./dir_module/".to_string();
let suggestions = completer.complete(&completion_str, completion_str.len());
match_suggestions(&vec!["sub.nu".into()], &suggestions);
match_suggestions(
&vec![
"mod.nu".into(),
#[cfg(windows)]
"sub module\\`".into(),
#[cfg(not(windows))]
"sub module/`".into(),
],
&suggestions,
);
// Test nested nu script, with ending '`'
#[cfg(windows)]
let completion_str = "use `.\\dir_module\\sub module\\`".to_string();
#[cfg(not(windows))]
let completion_str = "use `./dir_module/sub module/`".to_string();
let suggestions = completer.complete(&completion_str, completion_str.len());
match_suggestions(&vec!["sub.nu`".into()], &suggestions);
let expected = vec![
"asdf.nu".into(),