Skip to content

Commit

Permalink
core: add confirmation prompt (#12495) (#12510)
Browse files Browse the repository at this point in the history
The commit adds a confirmation prompt when executing the `clear command history` command.

Signed-off-by: zhangyi <[email protected]>
  • Loading branch information
helloworldmygithub authored May 11, 2023
1 parent 4867d2a commit b04bac3
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { KeybindingRegistry, KeybindingContribution } from '../keybinding';
import { CommonMenus } from '../common-frontend-contribution';
import { CLEAR_COMMAND_HISTORY, quickCommand, QuickCommandService } from './quick-command-service';
import { QuickInputService } from './quick-input-service';
import { ConfirmDialog, Dialog } from '../dialogs';

@injectable()
export class QuickCommandFrontendContribution implements CommandContribution, KeybindingContribution, MenuContribution {
Expand All @@ -36,7 +37,17 @@ export class QuickCommandFrontendContribution implements CommandContribution, Ke
}
});
commands.registerCommand(CLEAR_COMMAND_HISTORY, {
execute: () => commands.clearCommandHistory(),
execute: async () => {
const shouldClear = await new ConfirmDialog({
title: nls.localizeByDefault('Clear Command History'),
msg: nls.localizeByDefault('Do you want to clear the history of recently used commands?'),
ok: nls.localizeByDefault('Clear'),
cancel: Dialog.CANCEL,
}).open();
if (shouldClear) {
commands.clearCommandHistory();
}
}
});
}

Expand Down

0 comments on commit b04bac3

Please sign in to comment.