Skip to content

Commit b892a48

Browse files
Code review fixes
Co-Authored-By: Veetaha <veetaha2@gmail.com>
1 parent 590af37 commit b892a48

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -417,22 +417,19 @@ fn loop_turn(
417417
if Some(resp.id) == loop_state.configuration_request_id {
418418
loop_state.configuration_request_id = None;
419419
if let Some(err) = resp.error {
420-
log::error!("failed fetch the server settings: {:?}", err)
421-
} else if resp.result.is_none() {
422-
log::error!("received empty server settings response from the client")
423-
} else {
424-
let new_config =
425-
serde_json::from_value::<Vec<ServerConfig>>(resp.result.unwrap())?
426-
.first()
427-
.expect(
428-
"The client is expected to always send a non-empty config data",
429-
)
430-
.to_owned();
420+
log::error!("failed to fetch the server settings: {:?}", err)
421+
} else if let Some(result) = resp.result {
422+
let new_config = serde_json::from_value::<Vec<ServerConfig>>(result)?
423+
.first()
424+
.expect("The client is expected to always send a non-empty config data")
425+
.to_owned();
431426
world_state.update_configuration(
432427
new_config.lru_capacity,
433428
get_options(&new_config, text_document_caps),
434429
get_feature_flags(&new_config, connection),
435430
);
431+
} else {
432+
log::error!("received empty server settings response from the client")
436433
}
437434
}
438435
}
@@ -673,7 +670,7 @@ fn on_notification(
673670
ConfigurationParams::default(),
674671
);
675672
msg_sender.send(request.into())?;
676-
loop_state.configuration_request_id.replace(request_id);
673+
loop_state.configuration_request_id = Some(request_id);
677674

678675
return Ok(());
679676
}

crates/rust-analyzer/src/world.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use ra_db::ExternSourceId;
3232
use rustc_hash::{FxHashMap, FxHashSet};
3333

3434
fn create_watcher(workspaces: &[ProjectWorkspace], options: &Options) -> CheckWatcher {
35+
// FIXME: Figure out the multi-workspace situation
3536
workspaces
3637
.iter()
3738
.find_map(|w| match w {

editors/code/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Config } from './config';
55
import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed';
66
import { SemanticTokensFeature, DocumentSemanticsTokensSignature } from 'vscode-languageclient/lib/semanticTokens.proposed';
77

8-
export function configToServerOptions(config: Config): object {
8+
export function configToServerOptions(config: Config) {
99
return {
1010
publishDecorations: !config.highlightingSemanticTokens,
1111
lruCapacity: config.lruCapacity,

editors/code/src/inlay_hints.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ export function activateInlayHints(ctx: Ctx) {
1717
) {
1818
return this.dispose();
1919
}
20-
if (!this.updater) this.updater = new HintsUpdater(ctx);
21-
22-
this.updater.syncCacheAndRenderHints();
20+
if (this.updater) {
21+
this.updater.syncCacheAndRenderHints();
22+
} else {
23+
this.updater = new HintsUpdater(ctx);
24+
}
2325
},
2426
dispose() {
2527
this.updater?.dispose();
@@ -126,7 +128,7 @@ class HintsUpdater implements Disposable {
126128
this.syncCacheAndRenderHints();
127129
}
128130

129-
public syncCacheAndRenderHints() {
131+
syncCacheAndRenderHints() {
130132
// FIXME: make inlayHints request pass an array of files?
131133
this.sourceFiles.forEach((file, uri) => this.fetchHints(file).then(hints => {
132134
if (!hints) return;

editors/code/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export async function activate(context: vscode.ExtensionContext) {
9595
vscode.workspace.onDidChangeConfiguration(
9696
_ => ctx?.client?.sendNotification('workspace/didChangeConfiguration', { settings: "" }),
9797
null,
98-
ctx?.subscriptions,
98+
ctx.subscriptions,
9999
);
100100
}
101101

0 commit comments

Comments
 (0)