diff options
author | Kirill Bulatov <[email protected]> | 2020-03-21 22:40:07 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-03-30 11:39:14 +0100 |
commit | b892a48740eef7a505bfbe2213c42c71e87f0bea (patch) | |
tree | 8f7115e538c3b21407eb17c604636eb3bb6362c8 | |
parent | 590af37bff2b5ec9a692f2468c98acf7f9f492c0 (diff) |
Code review fixes
Co-Authored-By: Veetaha <[email protected]>
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 21 | ||||
-rw-r--r-- | crates/rust-analyzer/src/world.rs | 1 | ||||
-rw-r--r-- | editors/code/src/client.ts | 2 | ||||
-rw-r--r-- | editors/code/src/inlay_hints.ts | 10 | ||||
-rw-r--r-- | editors/code/src/main.ts | 2 |
5 files changed, 18 insertions, 18 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index e1fcae136..7e96be319 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -417,22 +417,19 @@ fn loop_turn( | |||
417 | if Some(resp.id) == loop_state.configuration_request_id { | 417 | if Some(resp.id) == loop_state.configuration_request_id { |
418 | loop_state.configuration_request_id = None; | 418 | loop_state.configuration_request_id = None; |
419 | if let Some(err) = resp.error { | 419 | if let Some(err) = resp.error { |
420 | log::error!("failed fetch the server settings: {:?}", err) | 420 | log::error!("failed to fetch the server settings: {:?}", err) |
421 | } else if resp.result.is_none() { | 421 | } else if let Some(result) = resp.result { |
422 | log::error!("received empty server settings response from the client") | 422 | let new_config = serde_json::from_value::<Vec<ServerConfig>>(result)? |
423 | } else { | 423 | .first() |
424 | let new_config = | 424 | .expect("The client is expected to always send a non-empty config data") |
425 | serde_json::from_value::<Vec<ServerConfig>>(resp.result.unwrap())? | 425 | .to_owned(); |
426 | .first() | ||
427 | .expect( | ||
428 | "The client is expected to always send a non-empty config data", | ||
429 | ) | ||
430 | .to_owned(); | ||
431 | world_state.update_configuration( | 426 | world_state.update_configuration( |
432 | new_config.lru_capacity, | 427 | new_config.lru_capacity, |
433 | get_options(&new_config, text_document_caps), | 428 | get_options(&new_config, text_document_caps), |
434 | get_feature_flags(&new_config, connection), | 429 | get_feature_flags(&new_config, connection), |
435 | ); | 430 | ); |
431 | } else { | ||
432 | log::error!("received empty server settings response from the client") | ||
436 | } | 433 | } |
437 | } | 434 | } |
438 | } | 435 | } |
@@ -673,7 +670,7 @@ fn on_notification( | |||
673 | ConfigurationParams::default(), | 670 | ConfigurationParams::default(), |
674 | ); | 671 | ); |
675 | msg_sender.send(request.into())?; | 672 | msg_sender.send(request.into())?; |
676 | loop_state.configuration_request_id.replace(request_id); | 673 | loop_state.configuration_request_id = Some(request_id); |
677 | 674 | ||
678 | return Ok(()); | 675 | return Ok(()); |
679 | } | 676 | } |
diff --git a/crates/rust-analyzer/src/world.rs b/crates/rust-analyzer/src/world.rs index 2b5878ed9..01084f818 100644 --- a/crates/rust-analyzer/src/world.rs +++ b/crates/rust-analyzer/src/world.rs | |||
@@ -32,6 +32,7 @@ use ra_db::ExternSourceId; | |||
32 | use rustc_hash::{FxHashMap, FxHashSet}; | 32 | use rustc_hash::{FxHashMap, FxHashSet}; |
33 | 33 | ||
34 | fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> CheckWatcher { | 34 | fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> CheckWatcher { |
35 | // FIXME: Figure out the multi-workspace situation | ||
35 | workspaces | 36 | workspaces |
36 | .iter() | 37 | .iter() |
37 | .find_map(|w| match w { | 38 | .find_map(|w| match w { |
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 34965e2fb..d72ecc58f 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts | |||
@@ -5,7 +5,7 @@ import { Config } from './config'; | |||
5 | import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; | 5 | import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed'; |
6 | import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; | 6 | import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed'; |
7 | 7 | ||
8 | export function configToServerOptions(config: Config): object { | 8 | export function configToServerOptions(config: Config) { |
9 | return { | 9 | return { |
10 | publishDecorations: !config.highlightingSemanticTokens, | 10 | publishDecorations: !config.highlightingSemanticTokens, |
11 | lruCapacity: config.lruCapacity, | 11 | lruCapacity: config.lruCapacity, |
diff --git a/editors/code/src/inlay_hints.ts b/editors/code/src/inlay_hints.ts index 98663e0e3..6a8bd942e 100644 --- a/editors/code/src/inlay_hints.ts +++ b/editors/code/src/inlay_hints.ts | |||
@@ -17,9 +17,11 @@ export function activateInlayHints(ctx: Ctx) { | |||
17 | ) { | 17 | ) { |
18 | return this.dispose(); | 18 | return this.dispose(); |
19 | } | 19 | } |
20 | if (!this.updater) this.updater = new HintsUpdater(ctx); | 20 | if (this.updater) { |
21 | 21 | this.updater.syncCacheAndRenderHints(); | |
22 | this.updater.syncCacheAndRenderHints(); | 22 | } else { |
23 | this.updater = new HintsUpdater(ctx); | ||
24 | } | ||
23 | }, | 25 | }, |
24 | dispose() { | 26 | dispose() { |
25 | this.updater?.dispose(); | 27 | this.updater?.dispose(); |
@@ -126,7 +128,7 @@ class HintsUpdater implements Disposable { | |||
126 | this.syncCacheAndRenderHints(); | 128 | this.syncCacheAndRenderHints(); |
127 | } | 129 | } |
128 | 130 | ||
129 | public syncCacheAndRenderHints() { | 131 | syncCacheAndRenderHints() { |
130 | // FIXME: make inlayHints request pass an array of files? | 132 | // FIXME: make inlayHints request pass an array of files? |
131 | this.sourceFiles.forEach((file, uri) => this.fetchHints(file).then(hints => { | 133 | this.sourceFiles.forEach((file, uri) => this.fetchHints(file).then(hints => { |
132 | if (!hints) return; | 134 | if (!hints) return; |
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index 63d145db0..a46dbde33 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts | |||
@@ -95,7 +95,7 @@ export async function activate(context: vscode.ExtensionContext) { | |||
95 | vscode.workspace.onDidChangeConfiguration( | 95 | vscode.workspace.onDidChangeConfiguration( |
96 | _ => ctx?.client?.sendNotification('workspace/didChangeConfiguration', { settings: "" }), | 96 | _ => ctx?.client?.sendNotification('workspace/didChangeConfiguration', { settings: "" }), |
97 | null, | 97 | null, |
98 | ctx?.subscriptions, | 98 | ctx.subscriptions, |
99 | ); | 99 | ); |
100 | } | 100 | } |
101 | 101 | ||