fix(lsp): handle repeating patterns in registry correctly (#13275)

This commit is contained in:
Kitson Kelly 2022-01-04 17:42:33 +11:00 committed by GitHub
parent d9b130410b
commit 01ff7a8784
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 120 additions and 28 deletions

View file

@ -249,7 +249,11 @@ impl StringOrVec {
}
}
pub fn to_string(&self, maybe_key: Option<&Key>) -> String {
pub fn to_string(
&self,
maybe_key: Option<&Key>,
omit_initial_prefix: bool,
) -> String {
match self {
Self::String(s) => s.clone(),
Self::Vec(v) => {
@ -262,8 +266,12 @@ impl StringOrVec {
("/".to_string(), "".to_string())
};
let mut s = String::new();
for segment in v {
s.push_str(&format!("{}{}{}", prefix, segment, suffix));
for (i, segment) in v.iter().enumerate() {
if omit_initial_prefix && i == 0 {
s.push_str(&format!("{}{}", segment, suffix));
} else {
s.push_str(&format!("{}{}{}", prefix, segment, suffix));
}
}
s
}