Skip to content

Commit 31db9c4

Browse files
CopilotTyriar
andcommitted
Add signal picker when no args provided to sendSignal command
Co-authored-by: Tyriar <[email protected]>
1 parent 0c348ec commit 31db9c4

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

src/vs/workbench/contrib/terminal/browser/terminalActions.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,39 @@ export const terminalSendSequenceCommand = async (accessor: ServicesAccessor, ar
139139

140140
export const terminalSendSignalCommand = async (accessor: ServicesAccessor, args: unknown) => {
141141
const instance = accessor.get(ITerminalService).activeInstance;
142-
if (instance) {
143-
const signal = isObject(args) && 'signal' in args ? toOptionalString(args.signal) : undefined;
144-
if (!signal) {
142+
if (!instance) {
143+
return;
144+
}
145+
146+
let signal = isObject(args) && 'signal' in args ? toOptionalString(args.signal) : undefined;
147+
148+
if (!signal) {
149+
const quickInputService = accessor.get(IQuickInputService);
150+
151+
const signalOptions: IQuickPickItem[] = [
152+
{ label: 'SIGINT', description: 'Interrupt process (Ctrl+C)' },
153+
{ label: 'SIGTERM', description: 'Terminate process gracefully' },
154+
{ label: 'SIGKILL', description: 'Force kill process' },
155+
{ label: 'SIGSTOP', description: 'Stop process' },
156+
{ label: 'SIGCONT', description: 'Continue process' },
157+
{ label: 'SIGHUP', description: 'Hangup' },
158+
{ label: 'SIGQUIT', description: 'Quit process' },
159+
{ label: 'SIGUSR1', description: 'User-defined signal 1' },
160+
{ label: 'SIGUSR2', description: 'User-defined signal 2' }
161+
];
162+
163+
const selected = await quickInputService.pick(signalOptions, {
164+
placeHolder: localize('selectSignal', 'Select signal to send to terminal process')
165+
});
166+
167+
if (!selected) {
145168
return;
146169
}
147-
instance.sendSignal(signal);
170+
171+
signal = selected.label;
148172
}
173+
174+
instance.sendSignal(signal);
149175
};
150176

151177
export class TerminalLaunchHelpAction extends Action {

0 commit comments

Comments
 (0)