Skip to content

Extension restart fix #433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion vscode/l10n/bundle.l10n.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@
"jdk.workspace.new.prompt": "Input the directory path where the new file will be generated",
"jdk.extension.utils.error_message.failedHttpsRequest": "Failed to get {url} ({statusCode})",
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME} not enabled",
"jdk.telemetry.consent": "Allow anonymous telemetry data to be reported to Oracle? You may opt-out or in at any time from the Settings for jdk.telemetry.enabled."
"jdk.telemetry.consent": "Allow anonymous telemetry data to be reported to Oracle? You may opt-out or in at any time from the Settings for jdk.telemetry.enabled.",
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
}
4 changes: 3 additions & 1 deletion vscode/l10n/bundle.l10n.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@
"jdk.workspace.new.prompt": "新しいファイルを生成するディレクトリのパスを入力してください",
"jdk.extension.utils.error_message.failedHttpsRequest": "{url}の取得に失敗しました({statusCode})",
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME}が有効化されていません",
"jdk.telemetry.consent": "匿名テレメトリ・データをOracleにレポートすることを許可しますか。jdk.telemetry.enabledの設定からいつでもオプトアウトまたはオプトインできます。"
"jdk.telemetry.consent": "匿名テレメトリ・データをOracleにレポートすることを許可しますか。jdk.telemetry.enabledの設定からいつでもオプトアウトまたはオプトインできます。",
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
}
4 changes: 3 additions & 1 deletion vscode/l10n/bundle.l10n.zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@
"jdk.workspace.new.prompt": "输入生成新文件的目录路径",
"jdk.extension.utils.error_message.failedHttpsRequest": "无法获取 {url} ({statusCode})",
"jdk.extension.error_msg.notEnabled": "{SERVER_NAME} 未启用",
"jdk.telemetry.consent": "是否允许向 Oracle 报告匿名遥测数据?您随时可以通过 jdk.telemetry.enabled 对应的设置选择退出或加入。"
"jdk.telemetry.consent": "是否允许向 Oracle 报告匿名遥测数据?您随时可以通过 jdk.telemetry.enabled 对应的设置选择退出或加入。",
"jdk.configChanged": "Configurations updated for oracle java extenion , please reload the window to restart the extension.",
"jdk.configChangedFailed": "Error while updating extension configurations , please reload the window to restart the extension."
}
45 changes: 27 additions & 18 deletions vscode/src/lsp/clientPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
import { commands } from "vscode";
import { commands,window } from "vscode";
import { LOGGER } from "../logger";
import { NbProcessManager } from "./nbProcessManager";
import { clientInit } from "./initializer";
import { NbLanguageClient } from "./nbLanguageClient";
import { globalState } from "../globalState";
import { l10n } from "../localiser";

export class ClientPromise {
setClient!: [(c: NbLanguageClient) => void, (err: any) => void];
Expand Down Expand Up @@ -60,24 +61,32 @@ export class ClientPromise {
}

public restartExtension = async (nbProcessManager: NbProcessManager | null, notifyKill: boolean) => {
if (this.activationPending) {
LOGGER.warn("Server activation requested repeatedly, ignoring...");
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this return statement is removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. restartExtension gets triggered whenever the configurations are changed and in that case even if activationPending we would need to restart (as configs have changed).
  2. BTW this is linked with issue on windows, it gets stuck here because of the return statement sometimes . So to resolve that we need to remove this return and show the reload window to the user if required.

}
if (!nbProcessManager) {
if (nbProcessManager) {
try {
globalState.setDeactivated(true);
await this.stopClient();
await nbProcessManager.killProcess(notifyKill);
this.initialize();
clientInit();
} catch (error) {
LOGGER.error(`Error during activation: ${error}`);
const reloadNow: string = l10n.value("jdk.downloader.message.reload");
const dialogBoxMessage = l10n.value("jdk.configChangedFailed");
const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow);
if (selected === reloadNow) {
await commands.executeCommand('workbench.action.reloadWindow');
}
} finally {
this.activationPending = false;
}
}else{
LOGGER.error("Nbcode Process is null");
return;
}
try {
await this.stopClient();
await nbProcessManager.killProcess(notifyKill);
this.initialize();
clientInit();
} catch (error) {
LOGGER.error(`Error during activation: ${error}`);
throw error;
} finally {
this.activationPending = false;
const reloadNow: string = l10n.value("jdk.downloader.message.reload");
const dialogBoxMessage = l10n.value("jdk.configChanged");
const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow);
if (selected === reloadNow) {
await commands.executeCommand('workbench.action.reloadWindow');
}
}
}

Expand Down
8 changes: 1 addition & 7 deletions vscode/src/webviews/jdkDownloader/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,7 @@ export class JdkDownloaderAction {
dialogBoxMessage = l10n.value("jdk.downloader.message.completedInstallingJdk");
}
LOGGER.log(`JDK installation completed successfully`);

const reloadNow: string = l10n.value("jdk.downloader.message.reload");
const selected = await window.showInformationMessage(dialogBoxMessage, reloadNow);
if (selected === reloadNow) {
await this.downloaderView.disposeView();
await commands.executeCommand('workbench.action.reloadWindow');
}
await window.showInformationMessage(dialogBoxMessage);
}

private jdkInstallationManager = async () => {
Expand Down