mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 05:14:44 +02:00
Expand multiple dots in path in completions (#13725)
# Description
This is my first PR, and I'm looking for feedback to help me improve!
This PR fixes #13380 by expanding the path prior to parsing it.
Also I've removed some unused code in
[completion_common.rs](84e92bb02c/crates/nu-cli/src/completions/completion_common.rs
)
# User-Facing Changes
Auto-completion for "cd .../" now works by expanding to "cd ../../".
# Tests + Formatting
Formatted and added 2 tests for triple dots in the middle of a path and
at the end.
Also added a test for the expand_ndots() function.
This commit is contained in:
@ -152,6 +152,17 @@ mod test_expand_ndots {
|
||||
};
|
||||
assert_path_eq!(expand_ndots(path), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn trailing_dots() {
|
||||
let path = Path::new("/foo/bar/..");
|
||||
let expected = if cfg!(windows) {
|
||||
r"\foo\bar\.."
|
||||
} else {
|
||||
"/foo/bar/.."
|
||||
};
|
||||
assert_path_eq!(expand_ndots(path), expected);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user