diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-05-11 17:17:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-11 17:17:14 -0400 |
commit | 28a72d548801f81a96ff4bba750d8dc51a2b1567 (patch) | |
tree | 0a689e1256d6e20f071156f5c8d0f52758a58d2d /cli/lsp/config.rs | |
parent | c926bc0debd0df3bf62d5125a490f8675e70c6ef (diff) |
feat(lsp): ability to configure document pre-load limit (#19097)
Adds a `deno.preloadLimit` option (ex. `"deno.preloadLimit": 2000`)
which specifies how many file entries to traverse on the file system
when the lsp loads or its configuration changes.
Closes #18955
Diffstat (limited to 'cli/lsp/config.rs')
-rw-r--r-- | cli/lsp/config.rs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index f4b2d8c09..0a25e2b99 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -265,6 +265,10 @@ fn default_to_true() -> bool { true } +fn default_document_preload_limit() -> usize { + 1000 +} + fn empty_string_none<'de, D: serde::Deserializer<'de>>( d: D, ) -> Result<Option<String>, D::Error> { @@ -318,6 +322,10 @@ pub struct WorkspaceSettings { #[serde(default = "default_to_true")] pub lint: bool, + /// Limits the number of files that can be preloaded by the language server. + #[serde(default = "default_document_preload_limit")] + pub document_preload_limit: usize, + /// A flag that indicates if Dene should validate code against the unstable /// APIs for the workspace. #[serde(default)] @@ -354,6 +362,7 @@ impl Default for WorkspaceSettings { inlay_hints: Default::default(), internal_debug: false, lint: true, + document_preload_limit: default_document_preload_limit(), suggest: Default::default(), testing: Default::default(), tls_certificate: None, @@ -439,8 +448,8 @@ impl Config { } } - pub fn get_workspace_settings(&self) -> WorkspaceSettings { - self.settings.workspace.clone() + pub fn workspace_settings(&self) -> &WorkspaceSettings { + &self.settings.workspace } /// Set the workspace settings directly, which occurs during initialization @@ -714,7 +723,7 @@ mod tests { .set_workspace_settings(json!({})) .expect("could not update"); assert_eq!( - config.get_workspace_settings(), + config.workspace_settings().clone(), WorkspaceSettings { enable: false, enable_paths: Vec::new(), @@ -750,6 +759,7 @@ mod tests { }, internal_debug: false, lint: true, + document_preload_limit: 1_000, suggest: CompletionSettings { complete_function_calls: false, names: true, @@ -778,7 +788,7 @@ mod tests { .set_workspace_settings(json!({ "cache": "" })) .expect("could not update"); assert_eq!( - config.get_workspace_settings(), + config.workspace_settings().clone(), WorkspaceSettings::default() ); } @@ -790,7 +800,7 @@ mod tests { .set_workspace_settings(json!({ "import_map": "" })) .expect("could not update"); assert_eq!( - config.get_workspace_settings(), + config.workspace_settings().clone(), WorkspaceSettings::default() ); } @@ -802,7 +812,7 @@ mod tests { .set_workspace_settings(json!({ "tls_certificate": "" })) .expect("could not update"); assert_eq!( - config.get_workspace_settings(), + config.workspace_settings().clone(), WorkspaceSettings::default() ); } @@ -814,7 +824,7 @@ mod tests { .set_workspace_settings(json!({ "config": "" })) .expect("could not update"); assert_eq!( - config.get_workspace_settings(), + config.workspace_settings().clone(), WorkspaceSettings::default() ); } |