Skip to content

Commit 3705846

Browse files
Merge pull request microsoft#666 from microsoft/r_msrc_1.77_76846
[MSRC 76846] Use notification prompt before running a command
2 parents c3b6e77 + f87219d commit 3705846

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR, TERMINAL_COMMAND_
2626
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
2727
import { IDecoration, ITerminalAddon, Terminal } from 'xterm';
2828
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
29+
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
2930

3031
interface IDisposableDecoration { decoration: IDecoration; disposables: IDisposable[]; exitCode?: number; markProperties?: IMarkProperties }
3132

@@ -52,7 +53,8 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
5253
@ILifecycleService lifecycleService: ILifecycleService,
5354
@ICommandService private readonly _commandService: ICommandService,
5455
@IInstantiationService instantiationService: IInstantiationService,
55-
@IAudioCueService private readonly _audioCueService: IAudioCueService
56+
@IAudioCueService private readonly _audioCueService: IAudioCueService,
57+
@INotificationService private readonly _notificationService: INotificationService
5658
) {
5759
super();
5860
this._register(toDisposable(() => this._dispose()));
@@ -349,7 +351,15 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
349351
const labelRun = localize("terminal.rerunCommand", 'Rerun Command');
350352
actions.push({
351353
class: undefined, tooltip: labelRun, id: 'terminal.rerunCommand', label: labelRun, enabled: true,
352-
run: () => this._onDidRequestRunCommand.fire({ command })
354+
run: async () => {
355+
this._notificationService.prompt(Severity.Info, localize('rerun', 'Do you want to run the command: {0}', command.command), [{
356+
label: localize('yes', 'Yes'),
357+
run: () => this._onDidRequestRunCommand.fire({ command })
358+
}, {
359+
label: localize('no', 'No'),
360+
run: () => { }
361+
}]);
362+
}
353363
});
354364
const labelCopy = localize("terminal.copyCommand", 'Copy Command');
355365
actions.push({

0 commit comments

Comments
 (0)