Skip to content

Commit d95b796

Browse files
testforstephenrgrunber
authored andcommitted
Allow to clean workspace without pop-up notification
Signed-off-by: Jinbo Wang <[email protected]>
1 parent 3cdbb5e commit d95b796

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/extension.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
376376

377377
context.subscriptions.push(commands.registerCommand(Commands.OPEN_FORMATTER, async () => openFormatter(context.extensionPath)));
378378

379-
context.subscriptions.push(commands.registerCommand(Commands.CLEAN_WORKSPACE, () => cleanWorkspace(workspacePath)));
379+
context.subscriptions.push(commands.registerCommand(Commands.CLEAN_WORKSPACE, (force?: boolean) => cleanWorkspace(workspacePath, force)));
380380

381381
context.subscriptions.push(commands.registerCommand(Commands.GET_WORKSPACE_PATH, () => workspacePath));
382382

@@ -715,16 +715,18 @@ function makeRandomHexString(length) {
715715
return result;
716716
}
717717

718-
async function cleanWorkspace(workspacePath) {
719-
const doIt = 'Restart and delete';
720-
window.showWarningMessage('Are you sure you want to clean the Java language server workspace?', 'Cancel', doIt).then(selection => {
721-
if (selection === doIt) {
722-
ensureExists(workspacePath);
723-
const file = path.join(workspacePath, cleanWorkspaceFileName);
724-
fs.closeSync(fs.openSync(file, 'w'));
725-
commands.executeCommand(Commands.RELOAD_WINDOW);
718+
async function cleanWorkspace(workspacePath, force?: boolean) {
719+
if (!force) {
720+
const doIt = 'Restart and delete';
721+
const selection = await window.showWarningMessage('Are you sure you want to clean the Java language server workspace?', 'Cancel', doIt);
722+
if (selection !== doIt) {
723+
return;
726724
}
727-
});
725+
}
726+
ensureExists(workspacePath);
727+
const file = path.join(workspacePath, cleanWorkspaceFileName);
728+
fs.closeSync(fs.openSync(file, 'w'));
729+
commands.executeCommand(Commands.RELOAD_WINDOW);
728730
}
729731

730732
function openServerLogFile(workspacePath, column: ViewColumn = ViewColumn.Active): Thenable<boolean> {

0 commit comments

Comments
 (0)