mirror of
https://github.com/denoland/deno.git
synced 2025-09-08 03:30:54 +00:00
fix(lsp): better handling of folders in registry completions (#13250)
This commit is contained in:
parent
0ae46a975c
commit
2e72893fa2
2 changed files with 40 additions and 4 deletions
|
@ -733,7 +733,7 @@ impl Compiler {
|
|||
let prefix = k.prefix.clone().unwrap_or_default();
|
||||
let suffix = k.suffix.clone().unwrap_or_default();
|
||||
for segment in v {
|
||||
if self.validate {
|
||||
if !segment.is_empty() && self.validate {
|
||||
if let Some(re) = &self.matches[i] {
|
||||
if !re.is_match(segment) {
|
||||
return Err(anyhow!(
|
||||
|
@ -911,6 +911,33 @@ mod tests {
|
|||
assert_eq!(actual, "/x/y@v1.0.0/z/example.ts".to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_compiler_ends_with_sep() {
|
||||
let tokens = parse("/x/:a@:b/:c*", None).expect("could not parse");
|
||||
let mut params = HashMap::<StringOrNumber, StringOrVec>::new();
|
||||
params.insert(
|
||||
StringOrNumber::String("a".to_string()),
|
||||
StringOrVec::String("y".to_string()),
|
||||
);
|
||||
params.insert(
|
||||
StringOrNumber::String("b".to_string()),
|
||||
StringOrVec::String("v1.0.0".to_string()),
|
||||
);
|
||||
params.insert(
|
||||
StringOrNumber::String("c".to_string()),
|
||||
StringOrVec::Vec(vec![
|
||||
"z".to_string(),
|
||||
"example".to_string(),
|
||||
"".to_string(),
|
||||
]),
|
||||
);
|
||||
let compiler = Compiler::new(&tokens, None);
|
||||
let actual = compiler.to_path(¶ms);
|
||||
assert!(actual.is_ok());
|
||||
let actual = actual.unwrap();
|
||||
assert_eq!(actual, "/x/y@v1.0.0/z/example/".to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_string_to_regex() {
|
||||
test_path("/", None, &[("/test", None), ("/", Some(("/", 0, 1)))]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue