mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 08:23:24 +01:00
support forward slash for directory completion in Windows (#3201)
While the "main" separator in Windows is the backslash, it supports the forward slash as a separator too. Add support for this so that the behavior is similar to the way Windows PowerShell handles the forward slash: it is recognized as a separator, and when using <tab> for path completion the slash is reversed.
This commit is contained in:
parent
a5cdd22bfe
commit
840bd98e01
@ -15,7 +15,8 @@ pub struct PathSuggestion {
|
||||
impl PathCompleter {
|
||||
pub fn path_suggestions(&self, partial: &str, matcher: &dyn Matcher) -> Vec<PathSuggestion> {
|
||||
let expanded = nu_parser::expand_ndots(partial);
|
||||
let expanded = expanded.as_ref();
|
||||
let expanded = expanded.replace(std::path::is_separator, &SEP.to_string());
|
||||
let expanded: &str = expanded.as_ref();
|
||||
|
||||
let (base_dir_name, partial) = match expanded.rfind(SEP) {
|
||||
Some(pos) => expanded.split_at(pos + SEP.len_utf8()),
|
||||
|
@ -143,7 +143,7 @@ async fn maybe_autocd_dir<'a>(
|
||||
// - the command name ends in a path separator, or
|
||||
// - it's not a command on the path and no arguments were given.
|
||||
let name = &cmd.name;
|
||||
let path_name = if name.ends_with(std::path::MAIN_SEPARATOR)
|
||||
let path_name = if name.ends_with(std::path::is_separator)
|
||||
|| (cmd.args.is_empty()
|
||||
&& PathBuf::from(name).is_dir()
|
||||
&& dunce::canonicalize(name).is_ok()
|
||||
|
Loading…
Reference in New Issue
Block a user