summaryrefslogtreecommitdiff
path: root/cli/lsp/language_server.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-01-23 06:12:41 +0000
committerGitHub <noreply@github.com>2024-01-23 06:12:41 +0000
commitec97c7dd4b5c1be83639769990ca6d37345089ca (patch)
tree809e7e4c4571ad8e4fe4359277d0e0923af334cf /cli/lsp/language_server.rs
parent2af0c0a3c6ea017bef2481c1a1ce0806457d5427 (diff)
feat(lsp): include scope uri in "deno/didChangeDenoConfiguration" (#22002)
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r--cli/lsp/language_server.rs107
1 files changed, 60 insertions, 47 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs
index 8355b4fe2..87b33b5cb 100644
--- a/cli/lsp/language_server.rs
+++ b/cli/lsp/language_server.rs
@@ -1630,19 +1630,23 @@ impl Inner {
{
files_to_check.insert(url.clone());
}
- config_changes.extend(
- params
- .changes
- .iter()
- .filter(|e| files_to_check.contains(&e.uri))
- .map(|e| lsp_custom::DenoConfigurationChangeEvent {
- uri: e.uri.clone(),
- typ: lsp_custom::DenoConfigurationChangeType::from_file_change_type(
- e.typ,
- ),
- configuration_type: lsp_custom::DenoConfigurationType::DenoJson,
- }),
- );
+ if let Some(root_uri) = self.config.root_uri() {
+ config_changes.extend(
+ params
+ .changes
+ .iter()
+ .filter(|e| files_to_check.contains(&e.uri))
+ .map(|e| lsp_custom::DenoConfigurationChangeEvent {
+ scope_uri: root_uri.clone(),
+ file_uri: e.uri.clone(),
+ typ:
+ lsp_custom::DenoConfigurationChangeType::from_file_change_type(
+ e.typ,
+ ),
+ configuration_type: lsp_custom::DenoConfigurationType::DenoJson,
+ }),
+ );
+ }
if let Err(err) = self.update_tsconfig().await {
self.client.show_message(MessageType::WARNING, err);
}
@@ -1664,19 +1668,24 @@ impl Inner {
if let Some(package_json) = &self.maybe_package_json {
files_to_check.insert(package_json.specifier());
}
- config_changes.extend(
- params
- .changes
- .iter()
- .filter(|e| files_to_check.contains(&e.uri))
- .map(|e| lsp_custom::DenoConfigurationChangeEvent {
- uri: e.uri.clone(),
- typ: lsp_custom::DenoConfigurationChangeType::from_file_change_type(
- e.typ,
- ),
- configuration_type: lsp_custom::DenoConfigurationType::PackageJson,
- }),
- );
+ if let Some(root_uri) = self.config.root_uri() {
+ config_changes.extend(
+ params
+ .changes
+ .iter()
+ .filter(|e| files_to_check.contains(&e.uri))
+ .map(|e| lsp_custom::DenoConfigurationChangeEvent {
+ scope_uri: root_uri.clone(),
+ file_uri: e.uri.clone(),
+ typ:
+ lsp_custom::DenoConfigurationChangeType::from_file_change_type(
+ e.typ,
+ ),
+ configuration_type:
+ lsp_custom::DenoConfigurationType::PackageJson,
+ }),
+ );
+ }
touched = true;
}
@@ -3317,27 +3326,31 @@ impl tower_lsp::LanguageServer for LanguageServer {
ls.maybe_testing_server = Some(test_server);
}
- let mut config_events = vec![];
- if let Some(config_file) = ls.config.maybe_config_file() {
- config_events.push(lsp_custom::DenoConfigurationChangeEvent {
- uri: config_file.specifier.clone(),
- typ: lsp_custom::DenoConfigurationChangeType::Added,
- configuration_type: lsp_custom::DenoConfigurationType::DenoJson,
- });
- }
- if let Some(package_json) = &ls.maybe_package_json {
- config_events.push(lsp_custom::DenoConfigurationChangeEvent {
- uri: package_json.specifier(),
- typ: lsp_custom::DenoConfigurationChangeType::Added,
- configuration_type: lsp_custom::DenoConfigurationType::PackageJson,
- });
- }
- if !config_events.is_empty() {
- ls.client.send_did_change_deno_configuration_notification(
- lsp_custom::DidChangeDenoConfigurationNotificationParams {
- changes: config_events,
- },
- );
+ if let Some(root_uri) = ls.config.root_uri() {
+ let mut config_events = vec![];
+ if let Some(config_file) = ls.config.maybe_config_file() {
+ config_events.push(lsp_custom::DenoConfigurationChangeEvent {
+ scope_uri: root_uri.clone(),
+ file_uri: config_file.specifier.clone(),
+ typ: lsp_custom::DenoConfigurationChangeType::Added,
+ configuration_type: lsp_custom::DenoConfigurationType::DenoJson,
+ });
+ }
+ if let Some(package_json) = &ls.maybe_package_json {
+ config_events.push(lsp_custom::DenoConfigurationChangeEvent {
+ scope_uri: root_uri.clone(),
+ file_uri: package_json.specifier(),
+ typ: lsp_custom::DenoConfigurationChangeType::Added,
+ configuration_type: lsp_custom::DenoConfigurationType::PackageJson,
+ });
+ }
+ if !config_events.is_empty() {
+ ls.client.send_did_change_deno_configuration_notification(
+ lsp_custom::DidChangeDenoConfigurationNotificationParams {
+ changes: config_events,
+ },
+ );
+ }
}
(ls.client.clone(), ls.http_client.clone())