Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use notification prompt before running a command #179702

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR, TERMINAL_COMMAND_
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
import { IDecoration, ITerminalAddon, Terminal } from 'xterm';
import { AudioCue, IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';

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

Expand All @@ -52,7 +53,8 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
@ILifecycleService lifecycleService: ILifecycleService,
@ICommandService private readonly _commandService: ICommandService,
@IInstantiationService instantiationService: IInstantiationService,
@IAudioCueService private readonly _audioCueService: IAudioCueService
@IAudioCueService private readonly _audioCueService: IAudioCueService,
@INotificationService private readonly _notificationService: INotificationService
) {
super();
this._register(toDisposable(() => this._dispose()));
Expand Down Expand Up @@ -349,7 +351,15 @@ export class DecorationAddon extends Disposable implements ITerminalAddon {
const labelRun = localize("terminal.rerunCommand", 'Rerun Command');
actions.push({
class: undefined, tooltip: labelRun, id: 'terminal.rerunCommand', label: labelRun, enabled: true,
run: () => this._onDidRequestRunCommand.fire({ command })
run: async () => {
this._notificationService.prompt(Severity.Info, localize('rerun', 'Do you want to run the command: {0}', command.command), [{
label: localize('yes', 'Yes'),
run: () => this._onDidRequestRunCommand.fire({ command })
}, {
label: localize('no', 'No'),
run: () => { }
}]);
}
});
const labelCopy = localize("terminal.copyCommand", 'Copy Command');
actions.push({
Expand Down