Skip to content

Commit 45a6eed

Browse files
zthcristianoc
authored andcommitted
ensure existing config is synced up on init
1 parent 8d6000d commit 45a6eed

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

client/src/extension.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ export function activate(context: ExtensionContext) {
130130
// Notify the server about file changes to '.clientrc files contained in the workspace
131131
fileEvents: workspace.createFileSystemWatcher("**/.clientrc"),
132132
},
133+
// We'll send the initial configuration in here, but this might be
134+
// problematic because every consumer of the LS will need to mimic this.
135+
// We'll leave it like this for now, but might be worth revisiting later on.
136+
initializationOptions: {
137+
extensionConfiguration: workspace.getConfiguration("rescript.settings"),
138+
},
133139
};
134140

135141
// Create the language client and start the client.
@@ -199,8 +205,7 @@ export function activate(context: ExtensionContext) {
199205
codeAnalysisRunningStatusBarItem.command =
200206
"rescript-vscode.stop_code_analysis";
201207
codeAnalysisRunningStatusBarItem.show();
202-
codeAnalysisRunningStatusBarItem.text =
203-
"$(debug-stop) Stop Code Analyzer";
208+
codeAnalysisRunningStatusBarItem.text = "$(debug-stop) Stop Code Analyzer";
204209

205210
customCommands.codeAnalysisWithReanalyze(
206211
inCodeAnalysisState.activatedFromDirectory,

server/src/server.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
DidChangeTextDocumentNotification,
1212
DidCloseTextDocumentNotification,
1313
DidChangeConfigurationNotification,
14+
InitializeParams,
1415
} from "vscode-languageserver-protocol";
1516
import * as utils from "./utils";
1617
import * as codeActions from "./codeActions";
@@ -281,8 +282,6 @@ if (process.argv.includes("--stdio")) {
281282
process.on("message", onMessage);
282283
}
283284

284-
askForAllCurrentConfiguration();
285-
286285
function hover(msg: p.RequestMessage) {
287286
let params = msg.params as p.HoverParams;
288287
let filePath = fileURLToPath(params.textDocument.uri);
@@ -860,8 +859,14 @@ function onMessage(msg: m.Message) {
860859
askForAllCurrentConfiguration();
861860
}, 10_000);
862861

863-
// Pull config right away as we've initied.
864-
askForAllCurrentConfiguration();
862+
// Save initial configuration, if present
863+
let initParams = msg.params as InitializeParams;
864+
let initialConfiguration = initParams.initializationOptions
865+
?.extensionConfiguration as extensionConfiguration | undefined;
866+
867+
if (initialConfiguration != null) {
868+
extensionConfiguration = initialConfiguration;
869+
}
865870

866871
send(response);
867872
} else if (msg.method === "initialized") {

0 commit comments

Comments
 (0)