Skip to content

Commit e07f677

Browse files
committed
Split send signal and sequence into own contribs
1 parent c87100c commit e07f677

File tree

4 files changed

+100
-87
lines changed

4 files changed

+100
-87
lines changed

src/vs/workbench/contrib/terminal/terminal.all.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import '../terminalContrib/stickyScroll/browser/terminal.stickyScroll.contributi
2727
import '../terminalContrib/quickAccess/browser/terminal.quickAccess.contribution.js';
2828
import '../terminalContrib/quickFix/browser/terminal.quickFix.contribution.js';
2929
import '../terminalContrib/typeAhead/browser/terminal.typeAhead.contribution.js';
30-
import '../terminalContrib/sendCommands/browser/terminal.sendCommands.contribution.js';
30+
import '../terminalContrib/sendSequence/browser/terminal.sendSequence.contribution.js';
31+
import '../terminalContrib/sendSignal/browser/terminal.sendSignal.contribution.js';
3132
import '../terminalContrib/suggest/browser/terminal.suggest.contribution.js';
3233
import '../terminalContrib/chat/browser/terminal.initialHint.contribution.js';
3334
import '../terminalContrib/wslRecommendation/browser/terminal.wslRecommendation.contribution.js';

src/vs/workbench/contrib/terminalContrib/sendCommands/common/terminal.sendCommands.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/vs/workbench/contrib/terminalContrib/sendCommands/browser/terminal.sendCommands.contribution.ts renamed to src/vs/workbench/contrib/terminalContrib/sendSequence/browser/terminal.sendSequence.contribution.ts

Lines changed: 8 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@ import { localize, localize2 } from '../../../../../nls.js';
1111
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from '../../../../../platform/accessibility/common/accessibility.js';
1212
import { ContextKeyExpr, type ContextKeyExpression } from '../../../../../platform/contextkey/common/contextkey.js';
1313
import type { ServicesAccessor } from '../../../../../platform/instantiation/common/instantiation.js';
14-
import { KeybindingsRegistry, type IKeybindings, KeybindingWeight } from '../../../../../platform/keybinding/common/keybindingsRegistry.js';
15-
import { IQuickInputService, type QuickPickItem } from '../../../../../platform/quickinput/common/quickInput.js';
14+
import { KeybindingsRegistry, KeybindingWeight, type IKeybindings } from '../../../../../platform/keybinding/common/keybindingsRegistry.js';
15+
import { IQuickInputService } from '../../../../../platform/quickinput/common/quickInput.js';
1616
import { GeneralShellType, WindowsShellType } from '../../../../../platform/terminal/common/terminal.js';
1717
import { IWorkspaceContextService } from '../../../../../platform/workspace/common/workspace.js';
1818
import { IConfigurationResolverService } from '../../../../services/configurationResolver/common/configurationResolver.js';
1919
import { IHistoryService } from '../../../../services/history/common/history.js';
2020
import { ITerminalService } from '../../../terminal/browser/terminal.js';
2121
import { registerTerminalAction } from '../../../terminal/browser/terminalActions.js';
2222
import { TerminalContextKeys, TerminalContextKeyStrings } from '../../../terminal/common/terminalContextKey.js';
23-
import { TerminalSendCommandsCommandId } from '../common/terminal.sendCommands.js';
23+
24+
export const enum TerminalSendSequenceCommandId {
25+
SendSequence = 'workbench.action.terminal.sendSequence',
26+
}
2427

2528
function toOptionalString(obj: unknown): string | undefined {
2629
return isString(obj) ? obj : undefined;
@@ -73,7 +76,7 @@ export const terminalSendSequenceCommand = async (accessor: ServicesAccessor, ar
7376

7477
const sendSequenceString = localize2('sendSequence', "Send Sequence");
7578
registerTerminalAction({
76-
id: TerminalSendCommandsCommandId.SendSequence,
79+
id: TerminalSendSequenceCommandId.SendSequence,
7780
title: sendSequenceString,
7881
f1: true,
7982
metadata: {
@@ -95,81 +98,9 @@ registerTerminalAction({
9598
run: (c, accessor, args) => terminalSendSequenceCommand(accessor, args)
9699
});
97100

98-
const sendSignalString = localize2('sendSignal', "Send Signal");
99-
registerTerminalAction({
100-
id: TerminalSendCommandsCommandId.SendSignal,
101-
title: sendSignalString,
102-
f1: !isWindows,
103-
metadata: {
104-
description: sendSignalString.value,
105-
args: [{
106-
name: 'args',
107-
schema: {
108-
type: 'object',
109-
required: ['signal'],
110-
properties: {
111-
signal: {
112-
description: localize('sendSignal.signal.desc', "The signal to send to the terminal process (e.g., 'SIGTERM', 'SIGINT', 'SIGKILL')"),
113-
type: 'string'
114-
}
115-
},
116-
}
117-
}]
118-
},
119-
run: async (c, accessor, args) => {
120-
const quickInputService = accessor.get(IQuickInputService);
121-
const instance = c.service.activeInstance;
122-
if (!instance) {
123-
return;
124-
}
125-
126-
let signal = isObject(args) && 'signal' in args ? toOptionalString(args.signal) : undefined;
127-
128-
if (!signal) {
129-
const signalOptions: QuickPickItem[] = [
130-
{ label: 'SIGINT', description: localize('SIGINT', 'Interrupt process (Ctrl+C)') },
131-
{ label: 'SIGTERM', description: localize('SIGTERM', 'Terminate process gracefully') },
132-
{ label: 'SIGKILL', description: localize('SIGKILL', 'Force kill process') },
133-
{ label: 'SIGSTOP', description: localize('SIGSTOP', 'Stop process') },
134-
{ label: 'SIGCONT', description: localize('SIGCONT', 'Continue process') },
135-
{ label: 'SIGHUP', description: localize('SIGHUP', 'Hangup') },
136-
{ label: 'SIGQUIT', description: localize('SIGQUIT', 'Quit process') },
137-
{ label: 'SIGUSR1', description: localize('SIGUSR1', 'User-defined signal 1') },
138-
{ label: 'SIGUSR2', description: localize('SIGUSR2', 'User-defined signal 2') },
139-
{ type: 'separator' },
140-
{ label: localize('manualSignal', 'Manually enter signal') }
141-
];
142-
143-
const selected = await quickInputService.pick(signalOptions, {
144-
placeHolder: localize('selectSignal', 'Select signal to send to terminal process')
145-
});
146-
147-
if (!selected) {
148-
return;
149-
}
150-
151-
if (selected.label === localize('manualSignal', 'Manually enter signal')) {
152-
const inputSignal = await quickInputService.input({
153-
prompt: localize('enterSignal', 'Enter signal name (e.g., SIGTERM, SIGKILL)'),
154-
});
155-
156-
if (!inputSignal) {
157-
return;
158-
}
159-
160-
signal = inputSignal;
161-
} else {
162-
signal = selected.label;
163-
}
164-
}
165-
166-
await instance.sendSignal(signal);
167-
}
168-
});
169-
170101
export function registerSendSequenceKeybinding(text: string, rule: { when?: ContextKeyExpression } & IKeybindings): void {
171102
KeybindingsRegistry.registerCommandAndKeybindingRule({
172-
id: TerminalSendCommandsCommandId.SendSequence,
103+
id: TerminalSendSequenceCommandId.SendSequence,
173104
weight: KeybindingWeight.WorkbenchContrib,
174105
when: rule.when || TerminalContextKeys.focus,
175106
primary: rule.primary,
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { isWindows } from '../../../../../base/common/platform.js';
7+
import { isObject, isString } from '../../../../../base/common/types.js';
8+
import { localize, localize2 } from '../../../../../nls.js';
9+
import { IQuickInputService, type QuickPickItem } from '../../../../../platform/quickinput/common/quickInput.js';
10+
import { registerTerminalAction } from '../../../terminal/browser/terminalActions.js';
11+
12+
export const enum TerminalSendSignalCommandId {
13+
SendSignal = 'workbench.action.terminal.sendSignal',
14+
}
15+
16+
function toOptionalString(obj: unknown): string | undefined {
17+
return isString(obj) ? obj : undefined;
18+
}
19+
20+
const sendSignalString = localize2('sendSignal', "Send Signal");
21+
registerTerminalAction({
22+
id: TerminalSendSignalCommandId.SendSignal,
23+
title: sendSignalString,
24+
f1: !isWindows,
25+
metadata: {
26+
description: sendSignalString.value,
27+
args: [{
28+
name: 'args',
29+
schema: {
30+
type: 'object',
31+
required: ['signal'],
32+
properties: {
33+
signal: {
34+
description: localize('sendSignal.signal.desc', "The signal to send to the terminal process (e.g., 'SIGTERM', 'SIGINT', 'SIGKILL')"),
35+
type: 'string'
36+
}
37+
},
38+
}
39+
}]
40+
},
41+
run: async (c, accessor, args) => {
42+
const quickInputService = accessor.get(IQuickInputService);
43+
const instance = c.service.activeInstance;
44+
if (!instance) {
45+
return;
46+
}
47+
48+
let signal = isObject(args) && 'signal' in args ? toOptionalString(args.signal) : undefined;
49+
50+
if (!signal) {
51+
const signalOptions: QuickPickItem[] = [
52+
{ label: 'SIGINT', description: localize('SIGINT', 'Interrupt process (Ctrl+C)') },
53+
{ label: 'SIGTERM', description: localize('SIGTERM', 'Terminate process gracefully') },
54+
{ label: 'SIGKILL', description: localize('SIGKILL', 'Force kill process') },
55+
{ label: 'SIGSTOP', description: localize('SIGSTOP', 'Stop process') },
56+
{ label: 'SIGCONT', description: localize('SIGCONT', 'Continue process') },
57+
{ label: 'SIGHUP', description: localize('SIGHUP', 'Hangup') },
58+
{ label: 'SIGQUIT', description: localize('SIGQUIT', 'Quit process') },
59+
{ label: 'SIGUSR1', description: localize('SIGUSR1', 'User-defined signal 1') },
60+
{ label: 'SIGUSR2', description: localize('SIGUSR2', 'User-defined signal 2') },
61+
{ type: 'separator' },
62+
{ label: localize('manualSignal', 'Manually enter signal') }
63+
];
64+
65+
const selected = await quickInputService.pick(signalOptions, {
66+
placeHolder: localize('selectSignal', 'Select signal to send to terminal process')
67+
});
68+
69+
if (!selected) {
70+
return;
71+
}
72+
73+
if (selected.label === localize('manualSignal', 'Manually enter signal')) {
74+
const inputSignal = await quickInputService.input({
75+
prompt: localize('enterSignal', 'Enter signal name (e.g., SIGTERM, SIGKILL)'),
76+
});
77+
78+
if (!inputSignal) {
79+
return;
80+
}
81+
82+
signal = inputSignal;
83+
} else {
84+
signal = selected.label;
85+
}
86+
}
87+
88+
await instance.sendSignal(signal);
89+
}
90+
});

0 commit comments

Comments
 (0)