Update path completions to handle spaces (#5419)

This commit is contained in:
JT
2022-05-03 12:37:38 +12:00
committed by GitHub
parent 1a52460695
commit e36649f74b
6 changed files with 94 additions and 26 deletions

View File

@ -18,7 +18,7 @@ pub use parse_keywords::*;
pub use parser::{
is_math_expression_like, parse, parse_block, parse_duration_bytes, parse_external_call,
trim_quotes, unescape_unquote_string, Import,
trim_quotes, trim_quotes_str, unescape_unquote_string, Import,
};
#[cfg(feature = "plugin")]

View File

@ -126,6 +126,17 @@ pub fn trim_quotes(bytes: &[u8]) -> &[u8] {
}
}
pub fn trim_quotes_str(s: &str) -> &str {
if (s.starts_with('"') && s.ends_with('"') && s.len() > 1)
|| (s.starts_with('\'') && s.ends_with('\'') && s.len() > 1)
|| (s.starts_with('`') && s.ends_with('`') && s.len() > 1)
{
&s[1..(s.len() - 1)]
} else {
s
}
}
pub fn check_call(command: Span, sig: &Signature, call: &Call) -> Option<ParseError> {
// Allow the call to pass if they pass in the help flag
if call.named_iter().any(|(n, _, _)| n.item == "help") {