Skip to content

Commit d1d6676

Browse files
committed
Correct restart of language server client if python interpreter changed
1 parent 3575d2a commit d1d6676

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes to the "robotcode" extension will be documented in this file
66

77
- Provide better error messages if python and robot environment not matches RobotCode requirements
88
- fixes [#40](https://github.com/d-biehl/robotcode/issues/40)
9+
- Correct restart of language server client if python interpreter changed
910

1011
## 0.11.0
1112

vscode-client/languageclientsmanger.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ export class LanguageClientsManager {
108108
this.pythonManager.pythonExtension?.exports.settings.onDidChangeExecutionDetails(async (uri) => {
109109
if (uri !== undefined) {
110110
const folder = vscode.workspace.getWorkspaceFolder(uri);
111+
let needsRestart = false;
111112
if (folder !== undefined) {
112-
this._pythonValidPythonAndRobotEnv.delete(folder);
113+
needsRestart = this._pythonValidPythonAndRobotEnv.has(folder);
114+
if (needsRestart) this._pythonValidPythonAndRobotEnv.delete(folder);
113115
}
114-
await this.refresh(uri);
116+
await this.refresh(uri, needsRestart);
115117
} else {
116118
await this.restart();
117119
}
@@ -441,7 +443,7 @@ export class LanguageClientsManager {
441443
await this.refresh();
442444
}
443445

444-
public async refresh(uri?: vscode.Uri): Promise<void> {
446+
public async refresh(uri?: vscode.Uri, restart?: boolean): Promise<void> {
445447
await this.clientsMutex.dispatch(async () => {
446448
if (uri) {
447449
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
@@ -464,6 +466,13 @@ export class LanguageClientsManager {
464466

465467
const folders = new Set<vscode.WorkspaceFolder>();
466468

469+
if (uri != undefined && restart) {
470+
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
471+
if (workspaceFolder) {
472+
folders.add(workspaceFolder);
473+
}
474+
}
475+
467476
for (const document of vscode.workspace.textDocuments) {
468477
if (document.languageId === "robotframework") {
469478
const workspaceFolder = vscode.workspace.getWorkspaceFolder(document.uri);

0 commit comments

Comments
 (0)