Skip to content

Commit 53b0429

Browse files
committed
Fix for delete cache error on windows
1 parent e686355 commit 53b0429

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

vscode/src/extension.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ let nbProcess : ChildProcess | null = null;
7878
let debugPort: number = -1;
7979
let debugHash: string | undefined;
8080
let consoleLog: boolean = !!process.env['ENABLE_CONSOLE_LOG'];
81-
81+
let deactivated = false;
8282
export class NbLanguageClient extends LanguageClient {
8383
private _treeViewService: TreeViewService;
8484

@@ -328,7 +328,7 @@ class InitialPromise extends Promise<NbLanguageClient> {
328328

329329
export function activate(context: ExtensionContext): VSNetBeansAPI {
330330
let log = vscode.window.createOutputChannel(SERVER_NAME);
331-
331+
deactivated = false;
332332
var clientResolve : (x : NbLanguageClient) => void;
333333
var clientReject : (err : any) => void;
334334

@@ -514,16 +514,16 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
514514
vscode.window.showErrorMessage('Cannot find workspace path');
515515
return;
516516
}
517+
517518
const userDir = path.join(storagePath, "userdir");
518519
if (userDir && fs.existsSync(userDir)) {
519-
const confirmation = await vscode.window.showInformationMessage('Are you sure you want to delete cache for this workspace?',
520+
const confirmation = await vscode.window.showInformationMessage('Are you sure you want to delete cache for this workspace and reload the window?',
520521
'Yes', 'Cancel');
521522
if (confirmation === 'Yes') {
522-
await fs.promises.rmdir(userDir, {recursive : true});
523-
const res = await vscode.window.showInformationMessage('Cache cleared successfully for this workspace', 'Reload window');
524-
if (res === 'Reload window') {
525-
await vscode.commands.executeCommand('workbench.action.reloadWindow');
526-
}
523+
stopClient(client).then(() => killNbProcess(false, log)).then(() => {
524+
fs.promises.rmdir(userDir, {recursive : true});
525+
vscode.commands.executeCommand('workbench.action.reloadWindow')
526+
});
527527
}
528528
} else {
529529
vscode.window.showErrorMessage('Cannot find userdir path');
@@ -953,7 +953,7 @@ function doActivateWithJDK(specifiedJDK: string | null, context: ExtensionContex
953953
if (p == nbProcess && code != 0 && code) {
954954
vscode.window.showWarningMessage(`${SERVER_NAME} exited with ` + code);
955955
}
956-
if (stdErr?.match(/Cannot find java/) || os.type() === "Windows_NT" ) {
956+
if (stdErr?.match(/Cannot find java/) || (os.type() === "Windows_NT" && !deactivated) ) {
957957
vscode.window.showInformationMessage(
958958
"No JDK found!",
959959
"Download JDK and setup automatically"
@@ -1422,6 +1422,7 @@ function stopClient(clientPromise: Promise<LanguageClient>): Thenable<void> {
14221422
}
14231423

14241424
export function deactivate(): Thenable<void> {
1425+
deactivated=true;
14251426
if (nbProcess != null) {
14261427
nbProcess.kill();
14271428
}

0 commit comments

Comments
 (0)