Skip to content

Commit 8f02add

Browse files
committed
Added error handling
1 parent 53b0429 commit 8f02add

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-
let deactivated = false;
81+
let deactivated:boolean = true;
8282
export class NbLanguageClient extends LanguageClient {
8383
private _treeViewService: TreeViewService;
8484

@@ -327,8 +327,8 @@ class InitialPromise extends Promise<NbLanguageClient> {
327327
}
328328

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

@@ -517,14 +517,16 @@ export function activate(context: ExtensionContext): VSNetBeansAPI {
517517

518518
const userDir = path.join(storagePath, "userdir");
519519
if (userDir && fs.existsSync(userDir)) {
520-
const confirmation = await vscode.window.showInformationMessage('Are you sure you want to delete cache for this workspace and reload the window?',
520+
const confirmation = await vscode.window.showInformationMessage('Are you sure you want to delete cache for this workspace and reload the window ?',
521521
'Yes', 'Cancel');
522522
if (confirmation === 'Yes') {
523-
stopClient(client).then(() => killNbProcess(false, log)).then(() => {
524-
fs.promises.rmdir(userDir, {recursive : true});
525-
vscode.commands.executeCommand('workbench.action.reloadWindow')
526-
});
527-
}
523+
stopClient(client).then(() => { deactivated=true;
524+
return killNbProcess(false, log);})
525+
.then(() => fs.promises.rmdir(userDir, {recursive : true}))
526+
.then(()=>vscode.window.showInformationMessage("Cache deleted successfully",'Reload window'),
527+
(err)=> vscode.window.showErrorMessage('Error deleting the cache','Reload window'))
528+
.then(()=> {vscode.commands.executeCommand("workbench.action.reloadWindow")});
529+
}
528530
} else {
529531
vscode.window.showErrorMessage('Cannot find userdir path');
530532
}
@@ -1422,7 +1424,6 @@ function stopClient(clientPromise: Promise<LanguageClient>): Thenable<void> {
14221424
}
14231425

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

0 commit comments

Comments
 (0)