Skip to content

Commit 022bdb2

Browse files
committed
read diagnostics in change_configuration()
1 parent a18abde commit 022bdb2

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

tests/integration/lsp_tests.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ fn lsp_import_attributes() {
14151415
},
14161416
}));
14171417

1418-
client.did_open(json!({
1418+
client.did_open_raw(json!({
14191419
"textDocument": {
14201420
"uri": "file:///a/test.json",
14211421
"languageId": "json",
@@ -2092,7 +2092,6 @@ fn lsp_suggestion_actions_disabled() {
20922092
},
20932093
},
20942094
}));
2095-
client.read_diagnostics();
20962095
let diagnostics = client.did_open(json!({
20972096
"textDocument": {
20982097
"uri": temp_dir.url().join("file.ts").unwrap(),
@@ -14061,10 +14060,10 @@ fn lsp_node_modules_dir() {
1406114060
"arguments": [["npm:chalk", "npm:@types/node"], file_uri],
1406214061
}),
1406314062
);
14063+
client.read_diagnostics()
1406414064
};
1406514065

1406614066
cache(&mut client);
14067-
client.read_diagnostics();
1406814067

1406914068
assert!(!temp_dir.path().join("node_modules").exists());
1407014069

@@ -14095,15 +14094,12 @@ fn lsp_node_modules_dir() {
1409514094
"imports": {},
1409614095
},
1409714096
"unstable": [],
14098-
} }));
14097+
} }))
1409914098
};
14100-
refresh_config(&mut client);
14101-
14102-
let diagnostics = client.read_diagnostics();
14099+
let diagnostics = refresh_config(&mut client);
1410314100
assert_eq!(diagnostics.all().len(), 2, "{:#?}", diagnostics); // not cached
1410414101

1410514102
cache(&mut client);
14106-
client.read_diagnostics();
1410714103

1410814104
assert!(temp_dir.path().join("node_modules/chalk").exists());
1410914105
assert!(temp_dir.path().join("node_modules/@types/node").exists());
@@ -14115,10 +14111,7 @@ fn lsp_node_modules_dir() {
1411514111
"{ \"nodeModulesDir\": \"auto\" }\n",
1411614112
);
1411714113
refresh_config(&mut client);
14118-
client.read_diagnostics();
14119-
cache(&mut client);
14120-
14121-
let diagnostics = client.read_diagnostics();
14114+
let diagnostics = cache(&mut client);
1412214115
assert_eq!(diagnostics.all().len(), 0, "{:#?}", diagnostics);
1412314116

1412414117
assert!(lockfile_path.exists());
@@ -14195,7 +14188,7 @@ fn lsp_vendor_dir() {
1419514188
temp_dir.path().join("deno.json"),
1419614189
"{ \"vendor\": true, \"lock\": false }\n",
1419714190
);
14198-
client.change_configuration(json!({ "deno": {
14191+
let diagnostics = client.change_configuration(json!({ "deno": {
1419914192
"enable": true,
1420014193
"config": "./deno.json",
1420114194
"codeLens": {
@@ -14214,7 +14207,6 @@ fn lsp_vendor_dir() {
1421414207
"unstable": [],
1421514208
} }));
1421614209

14217-
let diagnostics = client.read_diagnostics();
1421814210
// won't be cached until a manual cache occurs
1421914211
assert_eq!(
1422014212
diagnostics

tests/util/server/src/lsp.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,10 @@ impl LspClient {
918918
self.write_notification("textDocument/didOpen", params);
919919
}
920920

921-
pub fn change_configuration(&mut self, config: Value) {
921+
pub fn change_configuration(
922+
&mut self,
923+
config: Value,
924+
) -> CollectedDiagnostics {
922925
self.config = config;
923926
if self.supports_workspace_configuration {
924927
self.write_notification(
@@ -932,6 +935,7 @@ impl LspClient {
932935
json!({ "settings": &self.config }),
933936
);
934937
}
938+
self.read_diagnostics()
935939
}
936940

937941
pub fn handle_configuration_request(&mut self) {

0 commit comments

Comments
 (0)