Skip to content

Commit 6ba861d

Browse files
mmahroussfda-odoo
authored andcommitted
[IMP] vscode: set serverConfigPath and restart on update
1 parent ffdb5f7 commit 6ba861d

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

vscode/client/extension.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,8 @@ async function initLanguageServerClient(context: ExtensionContext, outputChannel
327327
// Production - Client is going to run the server (for use within `.vsix` package)
328328
const cwd = path.join(__dirname, "..", "..");
329329
let log_level = String(workspace.getConfiguration().get("Odoo.serverLogLevel"));
330-
client = startLangServer(serverPath, ["--log-level", log_level], cwd, outputChannel);
330+
let config_path = String(workspace.getConfiguration().get("Odoo.serverConfigPath"));
331+
client = startLangServer(serverPath, ["--log-level", log_level, "--config-path", config_path], cwd, outputChannel);
331332
}
332333

333334
context.subscriptions.push(
@@ -459,6 +460,17 @@ async function initializeSubscriptions(context: ExtensionContext): Promise<void>
459460
if (event.affectsConfiguration("Odoo.disablePythonLanguageServerPopup") && !workspace.getConfiguration('Odoo').get("disablePythonLanguageServerPopup", false)){
460461
displayDisablePythonLSMessage()
461462
}
463+
// Restart LS client if log_level or config_path changes
464+
if (
465+
event.affectsConfiguration("Odoo.serverLogLevel") ||
466+
event.affectsConfiguration("Odoo.serverConfigPath")
467+
) {
468+
await stopClient();
469+
global.LSCLIENT = await initLanguageServerClient(context, global.OUTPUT_CHANNEL);
470+
await global.LSCLIENT.start();
471+
await setStatusConfig(context);
472+
return;
473+
}
462474
}
463475
catch (error) {
464476
global.LSCLIENT?.error(error);

vscode/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@
123123
"scope": "window",
124124
"type": "string",
125125
"description": "Profile active in this workspace"
126+
},
127+
"Odoo.serverConfigPath": {
128+
"scope": "window",
129+
"type": "string",
130+
"default": "",
131+
"description": "Optional path to the server configuration file"
126132
}
127133
}
128134
}

0 commit comments

Comments
 (0)