summaryrefslogtreecommitdiff
path: root/cli/lsp/registries.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-06-01 21:53:08 +1000
committerGitHub <noreply@github.com>2021-06-01 21:53:08 +1000
commitbb5bf91067e28cef869f5180dc73a9b86e368bdc (patch)
treeb32cf8ec12073f58bb0f5aa2672047485a582843 /cli/lsp/registries.rs
parent9abb899f5fd36da65aae78351df3f478f8363700 (diff)
feat(lsp): registry auto discovery (#10813)
Closes: #10194 Fixes: #10468
Diffstat (limited to 'cli/lsp/registries.rs')
-rw-r--r--cli/lsp/registries.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/cli/lsp/registries.rs b/cli/lsp/registries.rs
index 877f03be3..29ec3258b 100644
--- a/cli/lsp/registries.rs
+++ b/cli/lsp/registries.rs
@@ -219,7 +219,7 @@ fn validate_config(config: &RegistryConfigurationJson) -> Result<(), AnyError> {
}
#[derive(Debug, Clone, Deserialize)]
-struct RegistryConfigurationVariable {
+pub(crate) struct RegistryConfigurationVariable {
/// The name of the variable.
key: String,
/// The URL with variable substitutions of the endpoint that will provide
@@ -228,7 +228,7 @@ struct RegistryConfigurationVariable {
}
#[derive(Debug, Clone, Deserialize)]
-struct RegistryConfiguration {
+pub(crate) struct RegistryConfiguration {
/// A Express-like path which describes how URLs are composed for a registry.
schema: String,
/// The variables denoted in the `schema` should have a variable entry.
@@ -339,7 +339,7 @@ impl ModuleRegistry {
}
/// Attempt to fetch the configuration for a specific origin.
- async fn fetch_config(
+ pub(crate) async fn fetch_config(
&self,
origin: &str,
) -> Result<Vec<RegistryConfiguration>, AnyError> {
@@ -443,6 +443,11 @@ impl ModuleRegistry {
.await
{
let end = if p.is_some() { i + 1 } else { i };
+ let end = if end > tokens.len() {
+ tokens.len()
+ } else {
+ end
+ };
let compiler = Compiler::new(&tokens[..end], None);
for (idx, item) in items.into_iter().enumerate() {
let label = if let Some(p) = &p {