@codingame/monaco-vscode-xterm-common 37.2.0 → 37.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.d.ts +3 -3
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.js +39 -39
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollContribution.js +3 -3
- package/vscode/src/vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability.d.ts +0 -11
- package/vscode/src/vs/platform/terminal/common/capabilities/naiveCwdDetectionCapability.js +0 -26
- package/vscode/src/vs/platform/terminal/common/environmentVariable.d.ts +0 -86
- package/vscode/src/vs/platform/terminal/common/environmentVariable.js +0 -10
- package/vscode/src/vs/platform/terminal/common/environmentVariableCollection.d.ts +0 -17
- package/vscode/src/vs/platform/terminal/common/environmentVariableCollection.js +0 -218
- package/vscode/src/vs/platform/terminal/common/terminalRecorder.d.ts +0 -14
- package/vscode/src/vs/platform/terminal/common/terminalRecorder.js +0 -84
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostOutputChannel.d.ts +0 -22
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostOutputChannel.js +0 -48
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostPty.d.ts +0 -129
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostPty.js +0 -439
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostTerminalService.d.ts +0 -77
- package/vscode/src/vs/workbench/contrib/terminal/browser/agentHostTerminalService.js +0 -345
- package/vscode/src/vs/workbench/contrib/terminal/browser/ahpTerminalCommandSource.d.ts +0 -111
- package/vscode/src/vs/workbench/contrib/terminal/browser/ahpTerminalCommandSource.js +0 -138
- package/vscode/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.d.ts +0 -28
- package/vscode/src/vs/workbench/contrib/terminal/browser/environmentVariableInfo.js +0 -119
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalActions.d.ts +0 -104
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalActions.js +0 -1643
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalContextMenu.d.ts +0 -19
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalContextMenu.js +0 -54
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIconPicker.d.ts +0 -12
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIconPicker.js +0 -78
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.d.ts +0 -144
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalProcessManager.js +0 -806
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalResizeDebouncer.d.ts +0 -17
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalResizeDebouncer.js +0 -83
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalStatusList.d.ts +0 -57
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalStatusList.js +0 -139
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTabsList.d.ts +0 -45
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTabsList.js +0 -804
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTooltip.d.ts +0 -9
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalTooltip.js +0 -75
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/lineDataEventAddon.d.ts +0 -17
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/lineDataEventAddon.js +0 -61
- package/vscode/src/vs/workbench/contrib/terminal/common/basePty.d.ts +0 -38
- package/vscode/src/vs/workbench/contrib/terminal/common/basePty.js +0 -127
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.d.ts +0 -38
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalEnvironment.js +0 -321
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalStorageKeys.d.ts +0 -12
- package/vscode/src/vs/workbench/contrib/terminal/common/terminalStorageKeys.js +0 -17
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/media/stickyScroll.css +0 -49
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollColorRegistry.d.ts +0 -2
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollColorRegistry.js +0 -25
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.d.ts +0 -58
- package/vscode/src/vs/workbench/contrib/terminalContrib/stickyScroll/browser/terminalStickyScrollOverlay.js +0 -462
|
@@ -1,1643 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
-
import { isMouseEvent, getActiveWindow, isPointerEvent, isKeyboardEvent } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
4
|
-
import { Action } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
|
|
5
|
-
import { CancellationToken } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
6
|
-
import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
|
|
7
|
-
import { Iterable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/iterator';
|
|
8
|
-
import { KeyMod, KeyCode, KeyChord } from '@codingame/monaco-vscode-api/vscode/vs/base/common/keyCodes';
|
|
9
|
-
import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
|
|
10
|
-
import { isAbsolute } from '@codingame/monaco-vscode-api/vscode/vs/base/common/path';
|
|
11
|
-
import { isWindows } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
|
|
12
|
-
import { dirname } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
|
|
13
|
-
import { isObject, hasKey, isString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
14
|
-
import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
|
|
15
|
-
import { ICodeEditorService } from '@codingame/monaco-vscode-api/vscode/vs/editor/browser/services/codeEditorService.service';
|
|
16
|
-
import { ILanguageService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/languages/language.service';
|
|
17
|
-
import { EndOfLinePreference } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/model';
|
|
18
|
-
import { getIconClasses } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/getIconClasses';
|
|
19
|
-
import { IModelService } from '@codingame/monaco-vscode-api/vscode/vs/editor/common/services/model.service';
|
|
20
|
-
import { localize, localize2 } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
21
|
-
import { AccessibleViewProviderId } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/browser/accessibleView';
|
|
22
|
-
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibility/common/accessibility';
|
|
23
|
-
import { registerAction2, Action2, MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
|
|
24
|
-
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
25
|
-
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
26
|
-
import { ContextKeyExpr } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
|
|
27
|
-
import { FileKind } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
|
|
28
|
-
import { KeybindingWeight } from '@codingame/monaco-vscode-api/vscode/vs/platform/keybinding/common/keybindingsRegistry';
|
|
29
|
-
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
30
|
-
import { IListService } from '@codingame/monaco-vscode-api/vscode/vs/platform/list/browser/listService.service';
|
|
31
|
-
import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
|
|
32
|
-
import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
|
|
33
|
-
import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
|
|
34
|
-
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
35
|
-
import { TerminalCapability } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities';
|
|
36
|
-
import { TerminalLocation, TerminalExitReason, TerminalSettingId } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal';
|
|
37
|
-
import { createProfileSchemaEnums } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminalProfiles';
|
|
38
|
-
import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
|
|
39
|
-
import { IWorkspaceContextService } from '@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service';
|
|
40
|
-
import { PICK_WORKSPACE_FOLDER_COMMAND_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/browser/actions/workspaceCommands';
|
|
41
|
-
import { CLOSE_EDITOR_COMMAND_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/browser/parts/editor/editorCommands';
|
|
42
|
-
import { IConfigurationResolverService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/configurationResolver/common/configurationResolver.service';
|
|
43
|
-
import { ConfigurationResolverExpression } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/configurationResolver/common/configurationResolverExpression';
|
|
44
|
-
import { editorGroupToColumn } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupColumn';
|
|
45
|
-
import { IEditorGroupsService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
|
|
46
|
-
import { ACTIVE_GROUP, SIDE_GROUP, AUX_WINDOW_GROUP } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService';
|
|
47
|
-
import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
48
|
-
import { IPreferencesService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/preferences/common/preferences.service';
|
|
49
|
-
import { IRemoteAgentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/remote/common/remoteAgentService.service';
|
|
50
|
-
import { accessibleViewOnLastLine, accessibleViewCurrentProviderId, accessibleViewIsShown } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
|
|
51
|
-
import { TerminalCommandId, TERMINAL_VIEW_ID } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal';
|
|
52
|
-
import { ITerminalProfileResolverService, ITerminalProfileService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminal.service';
|
|
53
|
-
import { TerminalContextKeys } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminalContextKey';
|
|
54
|
-
import { terminalStrings } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminalStrings';
|
|
55
|
-
import { Direction } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal';
|
|
56
|
-
import { ITerminalEditingService, ITerminalEditorService, ITerminalInstanceService, ITerminalGroupService, ITerminalConfigurationService, ITerminalService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal.service';
|
|
57
|
-
import { isAuxiliaryWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/window';
|
|
58
|
-
import { InstanceContext } from './terminalContextMenu.js';
|
|
59
|
-
import { getIconId, getColorClass, getUriClasses } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminalIcon';
|
|
60
|
-
import { newTerminalIcon, killTerminalIcon } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminalIcons';
|
|
61
|
-
import { TerminalTabList } from './terminalTabsList.js';
|
|
62
|
-
import { ResourceContextKey } from '@codingame/monaco-vscode-api/vscode/vs/workbench/common/contextkeys';
|
|
63
|
-
import { SeparatorSelectOption } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/selectBox/selectBox';
|
|
64
|
-
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
65
|
-
|
|
66
|
-
const switchTerminalShowTabsTitle = ( localize(16820, "Show Tabs"));
|
|
67
|
-
const category = terminalStrings.actionCategory;
|
|
68
|
-
const sharedWhenClause = (() => {
|
|
69
|
-
const terminalAvailable = ( ContextKeyExpr.or(
|
|
70
|
-
TerminalContextKeys.processSupported,
|
|
71
|
-
TerminalContextKeys.terminalHasBeenCreated
|
|
72
|
-
));
|
|
73
|
-
return {
|
|
74
|
-
terminalAvailable,
|
|
75
|
-
terminalAvailable_and_opened: ( ContextKeyExpr.and(terminalAvailable, TerminalContextKeys.isOpen)),
|
|
76
|
-
terminalAvailable_and_editorActive: ( ContextKeyExpr.and(terminalAvailable, TerminalContextKeys.terminalEditorActive)),
|
|
77
|
-
terminalAvailable_and_singularSelection: ( ContextKeyExpr.and(terminalAvailable, TerminalContextKeys.tabsSingularSelection)),
|
|
78
|
-
focusInAny_and_normalBuffer: ( ContextKeyExpr.and(TerminalContextKeys.focusInAny, ( TerminalContextKeys.altBufferActive.negate())))
|
|
79
|
-
};
|
|
80
|
-
})();
|
|
81
|
-
async function getCwdForSplit(instance, folders, commandService, configService) {
|
|
82
|
-
switch (configService.config.splitCwd) {
|
|
83
|
-
case "workspaceRoot":
|
|
84
|
-
if (folders !== undefined && commandService !== undefined) {
|
|
85
|
-
if (folders.length === 1) {
|
|
86
|
-
return folders[0].uri;
|
|
87
|
-
} else if (folders.length > 1) {
|
|
88
|
-
const options = {
|
|
89
|
-
placeHolder: ( localize(16821, "Select current working directory for new terminal"))
|
|
90
|
-
};
|
|
91
|
-
const workspace = await commandService.executeCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, [options]);
|
|
92
|
-
if (!workspace) {
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
return Promise.resolve(workspace.uri);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return "";
|
|
99
|
-
case "initial":
|
|
100
|
-
return instance.getInitialCwd();
|
|
101
|
-
case "inherited":
|
|
102
|
-
return instance.getSpeculativeCwd();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
let TerminalLaunchHelpAction = class TerminalLaunchHelpAction extends Action {
|
|
106
|
-
constructor(_openerService) {
|
|
107
|
-
super("workbench.action.terminal.launchHelp", ( localize(16822, "Open Help")));
|
|
108
|
-
this._openerService = _openerService;
|
|
109
|
-
}
|
|
110
|
-
async run() {
|
|
111
|
-
this._openerService.open("https://aka.ms/vscode-troubleshoot-terminal-launch");
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
TerminalLaunchHelpAction = ( __decorate([( __param(0, IOpenerService))], TerminalLaunchHelpAction));
|
|
115
|
-
function registerTerminalAction(options) {
|
|
116
|
-
options.f1 = options.f1 ?? true;
|
|
117
|
-
options.category = options.category ?? category;
|
|
118
|
-
options.precondition = options.precondition ?? TerminalContextKeys.processSupported;
|
|
119
|
-
const runFunc = options.run;
|
|
120
|
-
const strictOptions = options;
|
|
121
|
-
delete strictOptions["run"];
|
|
122
|
-
return registerAction2(class extends Action2 {
|
|
123
|
-
constructor() {
|
|
124
|
-
super(strictOptions);
|
|
125
|
-
}
|
|
126
|
-
run(accessor, args, args2) {
|
|
127
|
-
return runFunc(getTerminalServices(accessor), accessor, args, args2);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
function parseActionArgs(args) {
|
|
132
|
-
if (Array.isArray(args)) {
|
|
133
|
-
if (args.every(e => e instanceof InstanceContext)) {
|
|
134
|
-
return args;
|
|
135
|
-
}
|
|
136
|
-
} else if (args instanceof InstanceContext) {
|
|
137
|
-
return [args];
|
|
138
|
-
}
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
function registerContextualInstanceAction(options) {
|
|
142
|
-
const originalRun = options.run;
|
|
143
|
-
return registerTerminalAction({
|
|
144
|
-
...options,
|
|
145
|
-
run: async (c, accessor, focusedInstanceArgs, allInstanceArgs) => {
|
|
146
|
-
let instances = getSelectedViewInstances2(accessor, allInstanceArgs);
|
|
147
|
-
if (!instances) {
|
|
148
|
-
const activeInstance = (options.activeInstanceType === "view" ? c.groupService : options.activeInstanceType === "editor" ? c.editorService : c.service).activeInstance;
|
|
149
|
-
if (!activeInstance) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
instances = [activeInstance];
|
|
153
|
-
}
|
|
154
|
-
const results = [];
|
|
155
|
-
for (const instance of instances) {
|
|
156
|
-
results.push(originalRun(instance, c, accessor, focusedInstanceArgs));
|
|
157
|
-
}
|
|
158
|
-
await Promise.all(results);
|
|
159
|
-
if (options.runAfter) {
|
|
160
|
-
options.runAfter(instances, c, accessor, focusedInstanceArgs);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
function registerActiveInstanceAction(options) {
|
|
166
|
-
const originalRun = options.run;
|
|
167
|
-
return registerTerminalAction({
|
|
168
|
-
...options,
|
|
169
|
-
run: (c, accessor, args) => {
|
|
170
|
-
const activeInstance = c.service.activeInstance;
|
|
171
|
-
if (activeInstance) {
|
|
172
|
-
return originalRun(activeInstance, c, accessor, args);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
function registerActiveXtermAction(options) {
|
|
178
|
-
const originalRun = options.run;
|
|
179
|
-
return registerTerminalAction({
|
|
180
|
-
...options,
|
|
181
|
-
run: (c, accessor, args) => {
|
|
182
|
-
const activeDetached = Iterable.find(c.service.detachedInstances, d => d.xterm.isFocused);
|
|
183
|
-
if (activeDetached) {
|
|
184
|
-
return originalRun(activeDetached.xterm, accessor, activeDetached, args);
|
|
185
|
-
}
|
|
186
|
-
const activeInstance = c.service.activeInstance;
|
|
187
|
-
if (activeInstance?.xterm) {
|
|
188
|
-
return originalRun(activeInstance.xterm, accessor, activeInstance, args);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
function getTerminalServices(accessor) {
|
|
194
|
-
return {
|
|
195
|
-
service: accessor.get(ITerminalService),
|
|
196
|
-
configService: accessor.get(ITerminalConfigurationService),
|
|
197
|
-
groupService: accessor.get(ITerminalGroupService),
|
|
198
|
-
instanceService: accessor.get(ITerminalInstanceService),
|
|
199
|
-
editorService: accessor.get(ITerminalEditorService),
|
|
200
|
-
editingService: accessor.get(ITerminalEditingService),
|
|
201
|
-
profileService: accessor.get(ITerminalProfileService),
|
|
202
|
-
profileResolverService: accessor.get(ITerminalProfileResolverService)
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
function registerTerminalActions() {
|
|
206
|
-
registerTerminalAction({
|
|
207
|
-
id: TerminalCommandId.NewInActiveWorkspace,
|
|
208
|
-
title: ( localize2(16823, "Create New Terminal (In Active Workspace)")),
|
|
209
|
-
run: async c => {
|
|
210
|
-
if (c.service.isProcessSupportRegistered) {
|
|
211
|
-
const instance = await c.service.createTerminal({
|
|
212
|
-
location: c.configService.defaultLocation
|
|
213
|
-
});
|
|
214
|
-
if (!instance) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
c.service.setActiveInstance(instance);
|
|
218
|
-
await focusActiveTerminal(instance, c);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
refreshTerminalActions([]);
|
|
223
|
-
registerTerminalAction({
|
|
224
|
-
id: TerminalCommandId.CreateTerminalEditor,
|
|
225
|
-
title: ( localize2(16824, "Create New Terminal in Editor Area")),
|
|
226
|
-
run: async (c, _, args) => {
|
|
227
|
-
function isCreateTerminalOptions(obj) {
|
|
228
|
-
return isObject(obj) && "location" in obj;
|
|
229
|
-
}
|
|
230
|
-
const options = isCreateTerminalOptions(args) ? args : {
|
|
231
|
-
location: {
|
|
232
|
-
viewColumn: ACTIVE_GROUP
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
const instance = await c.service.createTerminal(options);
|
|
236
|
-
await instance.focusWhenReady();
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
registerTerminalAction({
|
|
240
|
-
id: TerminalCommandId.CreateTerminalEditorSameGroup,
|
|
241
|
-
title: ( localize2(16824, "Create New Terminal in Editor Area")),
|
|
242
|
-
f1: false,
|
|
243
|
-
run: async (c, accessor, args) => {
|
|
244
|
-
const editorGroupsService = accessor.get(IEditorGroupsService);
|
|
245
|
-
const instance = await c.service.createTerminal({
|
|
246
|
-
location: {
|
|
247
|
-
viewColumn: editorGroupToColumn(editorGroupsService, editorGroupsService.activeGroup)
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
await instance.focusWhenReady();
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
registerTerminalAction({
|
|
254
|
-
id: TerminalCommandId.CreateTerminalEditorSide,
|
|
255
|
-
title: ( localize2(16825, "Create New Terminal in Editor Area to the Side")),
|
|
256
|
-
run: async c => {
|
|
257
|
-
const instance = await c.service.createTerminal({
|
|
258
|
-
location: {
|
|
259
|
-
viewColumn: SIDE_GROUP
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
await instance.focusWhenReady();
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
registerTerminalAction({
|
|
266
|
-
id: TerminalCommandId.NewInNewWindow,
|
|
267
|
-
title: terminalStrings.newInNewWindow,
|
|
268
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
269
|
-
keybinding: {
|
|
270
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyMod.Alt | KeyCode.Backquote,
|
|
271
|
-
mac: {
|
|
272
|
-
primary: KeyMod.WinCtrl | KeyMod.Shift | KeyMod.Alt | KeyCode.Backquote
|
|
273
|
-
},
|
|
274
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
275
|
-
},
|
|
276
|
-
run: async c => {
|
|
277
|
-
const instance = await c.service.createTerminal({
|
|
278
|
-
location: {
|
|
279
|
-
viewColumn: AUX_WINDOW_GROUP,
|
|
280
|
-
auxiliary: {
|
|
281
|
-
compact: true
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
});
|
|
285
|
-
await instance.focusWhenReady();
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
registerContextualInstanceAction({
|
|
289
|
-
id: TerminalCommandId.MoveToEditor,
|
|
290
|
-
title: terminalStrings.moveToEditor,
|
|
291
|
-
precondition: sharedWhenClause.terminalAvailable_and_opened,
|
|
292
|
-
activeInstanceType: "view",
|
|
293
|
-
run: (instance, c) => c.service.moveToEditor(instance),
|
|
294
|
-
runAfter: instances => instances.at(-1)?.focus()
|
|
295
|
-
});
|
|
296
|
-
registerContextualInstanceAction({
|
|
297
|
-
id: TerminalCommandId.MoveIntoNewWindow,
|
|
298
|
-
title: terminalStrings.moveIntoNewWindow,
|
|
299
|
-
precondition: sharedWhenClause.terminalAvailable_and_opened,
|
|
300
|
-
run: (instance, c) => c.service.moveIntoNewEditor(instance),
|
|
301
|
-
runAfter: instances => instances.at(-1)?.focus()
|
|
302
|
-
});
|
|
303
|
-
registerTerminalAction({
|
|
304
|
-
id: TerminalCommandId.MoveToTerminalPanel,
|
|
305
|
-
title: terminalStrings.moveToTerminalPanel,
|
|
306
|
-
precondition: sharedWhenClause.terminalAvailable_and_editorActive,
|
|
307
|
-
run: (c, _, args) => {
|
|
308
|
-
const source = toOptionalUri(args) ?? c.editorService.activeInstance;
|
|
309
|
-
if (source) {
|
|
310
|
-
c.service.moveToTerminalView(source);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
registerTerminalAction({
|
|
315
|
-
id: TerminalCommandId.FocusPreviousPane,
|
|
316
|
-
title: ( localize2(16826, "Focus Previous Terminal in Terminal Group")),
|
|
317
|
-
keybinding: {
|
|
318
|
-
primary: KeyMod.Alt | KeyCode.LeftArrow,
|
|
319
|
-
secondary: [KeyMod.Alt | KeyCode.UpArrow],
|
|
320
|
-
mac: {
|
|
321
|
-
primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.LeftArrow,
|
|
322
|
-
secondary: [KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.UpArrow]
|
|
323
|
-
},
|
|
324
|
-
when: ( ContextKeyExpr.and(TerminalContextKeys.focus, TerminalContextKeys.splitTerminalActive)),
|
|
325
|
-
weight: KeybindingWeight.WorkbenchContrib + 1
|
|
326
|
-
},
|
|
327
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
328
|
-
run: async c => {
|
|
329
|
-
c.groupService.activeGroup?.focusPreviousPane();
|
|
330
|
-
await c.groupService.showPanel(true);
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
registerTerminalAction({
|
|
334
|
-
id: TerminalCommandId.FocusNextPane,
|
|
335
|
-
title: ( localize2(16827, "Focus Next Terminal in Terminal Group")),
|
|
336
|
-
keybinding: {
|
|
337
|
-
primary: KeyMod.Alt | KeyCode.RightArrow,
|
|
338
|
-
secondary: [KeyMod.Alt | KeyCode.DownArrow],
|
|
339
|
-
mac: {
|
|
340
|
-
primary: KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.RightArrow,
|
|
341
|
-
secondary: [KeyMod.Alt | KeyMod.CtrlCmd | KeyCode.DownArrow]
|
|
342
|
-
},
|
|
343
|
-
when: ( ContextKeyExpr.and(TerminalContextKeys.focus, TerminalContextKeys.splitTerminalActive)),
|
|
344
|
-
weight: KeybindingWeight.WorkbenchContrib + 1
|
|
345
|
-
},
|
|
346
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
347
|
-
run: async c => {
|
|
348
|
-
c.groupService.activeGroup?.focusNextPane();
|
|
349
|
-
await c.groupService.showPanel(true);
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
registerTerminalAction({
|
|
353
|
-
id: TerminalCommandId.ResizePaneLeft,
|
|
354
|
-
title: ( localize2(16828, "Resize Terminal Left")),
|
|
355
|
-
keybinding: {
|
|
356
|
-
linux: {
|
|
357
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.LeftArrow
|
|
358
|
-
},
|
|
359
|
-
mac: {
|
|
360
|
-
primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.LeftArrow
|
|
361
|
-
},
|
|
362
|
-
when: TerminalContextKeys.focus,
|
|
363
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
364
|
-
},
|
|
365
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
366
|
-
run: c => c.groupService.activeGroup?.resizePane(Direction.Left)
|
|
367
|
-
});
|
|
368
|
-
registerTerminalAction({
|
|
369
|
-
id: TerminalCommandId.ResizePaneRight,
|
|
370
|
-
title: ( localize2(16829, "Resize Terminal Right")),
|
|
371
|
-
keybinding: {
|
|
372
|
-
linux: {
|
|
373
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.RightArrow
|
|
374
|
-
},
|
|
375
|
-
mac: {
|
|
376
|
-
primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.RightArrow
|
|
377
|
-
},
|
|
378
|
-
when: TerminalContextKeys.focus,
|
|
379
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
380
|
-
},
|
|
381
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
382
|
-
run: c => c.groupService.activeGroup?.resizePane(Direction.Right)
|
|
383
|
-
});
|
|
384
|
-
registerTerminalAction({
|
|
385
|
-
id: TerminalCommandId.ResizePaneUp,
|
|
386
|
-
title: ( localize2(16830, "Resize Terminal Up")),
|
|
387
|
-
keybinding: {
|
|
388
|
-
mac: {
|
|
389
|
-
primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.UpArrow
|
|
390
|
-
},
|
|
391
|
-
when: TerminalContextKeys.focus,
|
|
392
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
393
|
-
},
|
|
394
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
395
|
-
run: c => c.groupService.activeGroup?.resizePane(Direction.Up)
|
|
396
|
-
});
|
|
397
|
-
registerTerminalAction({
|
|
398
|
-
id: TerminalCommandId.ResizePaneDown,
|
|
399
|
-
title: ( localize2(16831, "Resize Terminal Down")),
|
|
400
|
-
keybinding: {
|
|
401
|
-
mac: {
|
|
402
|
-
primary: KeyMod.CtrlCmd | KeyMod.WinCtrl | KeyCode.DownArrow
|
|
403
|
-
},
|
|
404
|
-
when: TerminalContextKeys.focus,
|
|
405
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
406
|
-
},
|
|
407
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
408
|
-
run: c => c.groupService.activeGroup?.resizePane(Direction.Down)
|
|
409
|
-
});
|
|
410
|
-
registerTerminalAction({
|
|
411
|
-
id: TerminalCommandId.Focus,
|
|
412
|
-
title: terminalStrings.focus,
|
|
413
|
-
keybinding: {
|
|
414
|
-
when: ( ContextKeyExpr.and(
|
|
415
|
-
CONTEXT_ACCESSIBILITY_MODE_ENABLED,
|
|
416
|
-
accessibleViewOnLastLine,
|
|
417
|
-
( accessibleViewCurrentProviderId.isEqualTo(AccessibleViewProviderId.Terminal))
|
|
418
|
-
)),
|
|
419
|
-
primary: KeyMod.CtrlCmd | KeyCode.DownArrow,
|
|
420
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
421
|
-
},
|
|
422
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
423
|
-
run: async c => {
|
|
424
|
-
const instance = c.service.activeInstance || (await c.service.createTerminal({
|
|
425
|
-
location: TerminalLocation.Panel
|
|
426
|
-
}));
|
|
427
|
-
if (!instance) {
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
c.service.setActiveInstance(instance);
|
|
431
|
-
await focusActiveTerminal(instance, c);
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
registerTerminalAction({
|
|
435
|
-
id: TerminalCommandId.FocusTabs,
|
|
436
|
-
title: ( localize2(16832, "Focus Terminal Tabs View")),
|
|
437
|
-
keybinding: {
|
|
438
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Backslash,
|
|
439
|
-
weight: KeybindingWeight.WorkbenchContrib,
|
|
440
|
-
when: ( ContextKeyExpr.or(TerminalContextKeys.tabsFocus, TerminalContextKeys.focus))
|
|
441
|
-
},
|
|
442
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
443
|
-
run: c => c.groupService.focusTabs()
|
|
444
|
-
});
|
|
445
|
-
registerTerminalAction({
|
|
446
|
-
id: TerminalCommandId.FocusNext,
|
|
447
|
-
title: ( localize2(16833, "Focus Next Terminal Group")),
|
|
448
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
449
|
-
keybinding: {
|
|
450
|
-
primary: KeyMod.CtrlCmd | KeyCode.PageDown,
|
|
451
|
-
mac: {
|
|
452
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.BracketRight
|
|
453
|
-
},
|
|
454
|
-
when: ( ContextKeyExpr.and(TerminalContextKeys.focus, ( TerminalContextKeys.editorFocus.negate()))),
|
|
455
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
456
|
-
},
|
|
457
|
-
run: async c => {
|
|
458
|
-
c.groupService.setActiveGroupToNext();
|
|
459
|
-
await c.groupService.showPanel(true);
|
|
460
|
-
}
|
|
461
|
-
});
|
|
462
|
-
registerTerminalAction({
|
|
463
|
-
id: TerminalCommandId.FocusPrevious,
|
|
464
|
-
title: ( localize2(16834, "Focus Previous Terminal Group")),
|
|
465
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
466
|
-
keybinding: {
|
|
467
|
-
primary: KeyMod.CtrlCmd | KeyCode.PageUp,
|
|
468
|
-
mac: {
|
|
469
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.BracketLeft
|
|
470
|
-
},
|
|
471
|
-
when: ( ContextKeyExpr.and(TerminalContextKeys.focus, ( TerminalContextKeys.editorFocus.negate()))),
|
|
472
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
473
|
-
},
|
|
474
|
-
run: async c => {
|
|
475
|
-
c.groupService.setActiveGroupToPrevious();
|
|
476
|
-
await c.groupService.showPanel(true);
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
registerTerminalAction({
|
|
480
|
-
id: TerminalCommandId.RunSelectedText,
|
|
481
|
-
title: ( localize2(16835, "Run Selected Text In Active Terminal")),
|
|
482
|
-
run: async (c, accessor) => {
|
|
483
|
-
const codeEditorService = accessor.get(ICodeEditorService);
|
|
484
|
-
const editor = codeEditorService.getActiveCodeEditor();
|
|
485
|
-
if (!editor || !editor.hasModel()) {
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
const instance = await c.service.getActiveOrCreateInstance({
|
|
489
|
-
acceptsInput: true
|
|
490
|
-
});
|
|
491
|
-
const selection = editor.getSelection();
|
|
492
|
-
let text;
|
|
493
|
-
if (selection.isEmpty()) {
|
|
494
|
-
text = editor.getModel().getLineContent(selection.selectionStartLineNumber).trim();
|
|
495
|
-
} else {
|
|
496
|
-
const endOfLinePreference = isWindows ? EndOfLinePreference.LF : EndOfLinePreference.CRLF;
|
|
497
|
-
text = editor.getModel().getValueInRange(selection, endOfLinePreference);
|
|
498
|
-
}
|
|
499
|
-
instance.sendText(text, true, true);
|
|
500
|
-
await c.service.revealActiveTerminal(true);
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
registerTerminalAction({
|
|
504
|
-
id: TerminalCommandId.RunActiveFile,
|
|
505
|
-
title: ( localize2(16836, "Run Active File In Active Terminal")),
|
|
506
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
507
|
-
run: async (c, accessor) => {
|
|
508
|
-
const codeEditorService = accessor.get(ICodeEditorService);
|
|
509
|
-
const notificationService = accessor.get(INotificationService);
|
|
510
|
-
const workbenchEnvironmentService = accessor.get(IWorkbenchEnvironmentService);
|
|
511
|
-
const editor = codeEditorService.getActiveCodeEditor();
|
|
512
|
-
if (!editor || !editor.hasModel()) {
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
const instance = await c.service.getActiveOrCreateInstance({
|
|
516
|
-
acceptsInput: true
|
|
517
|
-
});
|
|
518
|
-
const isRemote = instance ? instance.hasRemoteAuthority : (workbenchEnvironmentService.remoteAuthority ? true : false);
|
|
519
|
-
const uri = editor.getModel().uri;
|
|
520
|
-
if ((!isRemote && uri.scheme !== Schemas.file && uri.scheme !== Schemas.vscodeUserData) || (isRemote && uri.scheme !== Schemas.vscodeRemote)) {
|
|
521
|
-
notificationService.warn(( localize(16837, "Only files on disk can be run in the terminal")));
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
await instance.sendPath(uri, true);
|
|
525
|
-
return c.groupService.showPanel();
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
registerActiveXtermAction({
|
|
529
|
-
id: TerminalCommandId.ScrollDownLine,
|
|
530
|
-
title: ( localize2(16838, "Scroll Down (Line)")),
|
|
531
|
-
keybinding: {
|
|
532
|
-
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageDown,
|
|
533
|
-
linux: {
|
|
534
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow
|
|
535
|
-
},
|
|
536
|
-
when: sharedWhenClause.focusInAny_and_normalBuffer,
|
|
537
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
538
|
-
},
|
|
539
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
540
|
-
run: xterm => xterm.scrollDownLine()
|
|
541
|
-
});
|
|
542
|
-
registerActiveXtermAction({
|
|
543
|
-
id: TerminalCommandId.ScrollDownPage,
|
|
544
|
-
title: ( localize2(16839, "Scroll Down (Page)")),
|
|
545
|
-
keybinding: {
|
|
546
|
-
primary: KeyMod.Shift | KeyCode.PageDown,
|
|
547
|
-
mac: {
|
|
548
|
-
primary: KeyCode.PageDown
|
|
549
|
-
},
|
|
550
|
-
when: sharedWhenClause.focusInAny_and_normalBuffer,
|
|
551
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
552
|
-
},
|
|
553
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
554
|
-
run: xterm => xterm.scrollDownPage()
|
|
555
|
-
});
|
|
556
|
-
registerActiveXtermAction({
|
|
557
|
-
id: TerminalCommandId.ScrollToBottom,
|
|
558
|
-
title: ( localize2(16840, "Scroll to Bottom")),
|
|
559
|
-
keybinding: {
|
|
560
|
-
primary: KeyMod.CtrlCmd | KeyCode.End,
|
|
561
|
-
linux: {
|
|
562
|
-
primary: KeyMod.Shift | KeyCode.End
|
|
563
|
-
},
|
|
564
|
-
when: sharedWhenClause.focusInAny_and_normalBuffer,
|
|
565
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
566
|
-
},
|
|
567
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
568
|
-
run: xterm => xterm.scrollToBottom()
|
|
569
|
-
});
|
|
570
|
-
registerActiveXtermAction({
|
|
571
|
-
id: TerminalCommandId.ScrollUpLine,
|
|
572
|
-
title: ( localize2(16841, "Scroll Up (Line)")),
|
|
573
|
-
keybinding: {
|
|
574
|
-
primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.PageUp,
|
|
575
|
-
linux: {
|
|
576
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow
|
|
577
|
-
},
|
|
578
|
-
when: sharedWhenClause.focusInAny_and_normalBuffer,
|
|
579
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
580
|
-
},
|
|
581
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
582
|
-
run: xterm => xterm.scrollUpLine()
|
|
583
|
-
});
|
|
584
|
-
registerActiveXtermAction({
|
|
585
|
-
id: TerminalCommandId.ScrollUpPage,
|
|
586
|
-
title: ( localize2(16842, "Scroll Up (Page)")),
|
|
587
|
-
f1: true,
|
|
588
|
-
keybinding: {
|
|
589
|
-
primary: KeyMod.Shift | KeyCode.PageUp,
|
|
590
|
-
mac: {
|
|
591
|
-
primary: KeyCode.PageUp
|
|
592
|
-
},
|
|
593
|
-
when: sharedWhenClause.focusInAny_and_normalBuffer,
|
|
594
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
595
|
-
},
|
|
596
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
597
|
-
run: xterm => xterm.scrollUpPage()
|
|
598
|
-
});
|
|
599
|
-
registerActiveXtermAction({
|
|
600
|
-
id: TerminalCommandId.ScrollToTop,
|
|
601
|
-
title: ( localize2(16843, "Scroll to Top")),
|
|
602
|
-
keybinding: {
|
|
603
|
-
primary: KeyMod.CtrlCmd | KeyCode.Home,
|
|
604
|
-
linux: {
|
|
605
|
-
primary: KeyMod.Shift | KeyCode.Home
|
|
606
|
-
},
|
|
607
|
-
when: sharedWhenClause.focusInAny_and_normalBuffer,
|
|
608
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
609
|
-
},
|
|
610
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
611
|
-
run: xterm => xterm.scrollToTop()
|
|
612
|
-
});
|
|
613
|
-
registerActiveXtermAction({
|
|
614
|
-
id: TerminalCommandId.ClearSelection,
|
|
615
|
-
title: ( localize2(16844, "Clear Selection")),
|
|
616
|
-
keybinding: {
|
|
617
|
-
primary: KeyCode.Escape,
|
|
618
|
-
when: ( ContextKeyExpr.and(
|
|
619
|
-
TerminalContextKeys.focusInAny,
|
|
620
|
-
TerminalContextKeys.textSelected,
|
|
621
|
-
TerminalContextKeys.notFindVisible
|
|
622
|
-
)),
|
|
623
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
624
|
-
},
|
|
625
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
626
|
-
run: xterm => {
|
|
627
|
-
if (xterm.hasSelection()) {
|
|
628
|
-
xterm.clearSelection();
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
});
|
|
632
|
-
registerTerminalAction({
|
|
633
|
-
id: TerminalCommandId.ChangeIcon,
|
|
634
|
-
title: terminalStrings.changeIcon,
|
|
635
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
636
|
-
run: (c, _, args) => getResourceOrActiveInstance(c, args)?.changeIcon()
|
|
637
|
-
});
|
|
638
|
-
registerTerminalAction({
|
|
639
|
-
id: TerminalCommandId.ChangeIconActiveTab,
|
|
640
|
-
title: terminalStrings.changeIcon,
|
|
641
|
-
f1: false,
|
|
642
|
-
precondition: sharedWhenClause.terminalAvailable_and_singularSelection,
|
|
643
|
-
run: async (c, accessor, args) => {
|
|
644
|
-
let icon;
|
|
645
|
-
if (c.groupService.lastAccessedMenu === "inline-tab") {
|
|
646
|
-
getResourceOrActiveInstance(c, args)?.changeIcon();
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
for (const terminal of getSelectedViewInstances(accessor) ?? []) {
|
|
650
|
-
icon = await terminal.changeIcon(icon);
|
|
651
|
-
}
|
|
652
|
-
}
|
|
653
|
-
});
|
|
654
|
-
registerTerminalAction({
|
|
655
|
-
id: TerminalCommandId.ChangeColor,
|
|
656
|
-
title: terminalStrings.changeColor,
|
|
657
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
658
|
-
run: (c, _, args) => getResourceOrActiveInstance(c, args)?.changeColor()
|
|
659
|
-
});
|
|
660
|
-
registerTerminalAction({
|
|
661
|
-
id: TerminalCommandId.ChangeColorActiveTab,
|
|
662
|
-
title: terminalStrings.changeColor,
|
|
663
|
-
f1: false,
|
|
664
|
-
precondition: sharedWhenClause.terminalAvailable_and_singularSelection,
|
|
665
|
-
run: async (c, accessor, args) => {
|
|
666
|
-
let color;
|
|
667
|
-
let i = 0;
|
|
668
|
-
if (c.groupService.lastAccessedMenu === "inline-tab") {
|
|
669
|
-
getResourceOrActiveInstance(c, args)?.changeColor();
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
for (const terminal of getSelectedViewInstances(accessor) ?? []) {
|
|
673
|
-
const skipQuickPick = i !== 0;
|
|
674
|
-
color = await terminal.changeColor(color, skipQuickPick);
|
|
675
|
-
i++;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
});
|
|
679
|
-
registerTerminalAction({
|
|
680
|
-
id: TerminalCommandId.Rename,
|
|
681
|
-
title: terminalStrings.rename,
|
|
682
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
683
|
-
run: (c, accessor, args) => renameWithQuickPick(c, accessor, args)
|
|
684
|
-
});
|
|
685
|
-
registerTerminalAction({
|
|
686
|
-
id: TerminalCommandId.RenameActiveTab,
|
|
687
|
-
title: terminalStrings.rename,
|
|
688
|
-
f1: false,
|
|
689
|
-
keybinding: {
|
|
690
|
-
primary: KeyCode.F2,
|
|
691
|
-
mac: {
|
|
692
|
-
primary: KeyCode.Enter
|
|
693
|
-
},
|
|
694
|
-
when: ( ContextKeyExpr.and(TerminalContextKeys.tabsFocus)),
|
|
695
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
696
|
-
},
|
|
697
|
-
precondition: sharedWhenClause.terminalAvailable_and_singularSelection,
|
|
698
|
-
run: async (c, accessor) => {
|
|
699
|
-
const terminalGroupService = accessor.get(ITerminalGroupService);
|
|
700
|
-
const notificationService = accessor.get(INotificationService);
|
|
701
|
-
const instances = getSelectedViewInstances(accessor);
|
|
702
|
-
const firstInstance = instances?.[0];
|
|
703
|
-
if (!firstInstance) {
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
if (terminalGroupService.lastAccessedMenu === "inline-tab") {
|
|
707
|
-
return renameWithQuickPick(c, accessor, firstInstance);
|
|
708
|
-
}
|
|
709
|
-
c.editingService.setEditingTerminal(firstInstance);
|
|
710
|
-
c.editingService.setEditable(firstInstance, {
|
|
711
|
-
validationMessage: value => validateTerminalName(value),
|
|
712
|
-
onFinish: async (value, success) => {
|
|
713
|
-
c.editingService.setEditable(firstInstance, null);
|
|
714
|
-
c.editingService.setEditingTerminal(undefined);
|
|
715
|
-
if (success) {
|
|
716
|
-
const promises = [];
|
|
717
|
-
for (const instance of instances) {
|
|
718
|
-
promises.push((async () => {
|
|
719
|
-
await instance.rename(value);
|
|
720
|
-
})());
|
|
721
|
-
}
|
|
722
|
-
try {
|
|
723
|
-
await Promise.all(promises);
|
|
724
|
-
} catch (e) {
|
|
725
|
-
notificationService.error(e);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
});
|
|
732
|
-
registerActiveInstanceAction({
|
|
733
|
-
id: TerminalCommandId.DetachSession,
|
|
734
|
-
title: ( localize2(16845, "Detach Session")),
|
|
735
|
-
run: activeInstance => activeInstance.detachProcessAndDispose(TerminalExitReason.User)
|
|
736
|
-
});
|
|
737
|
-
registerTerminalAction({
|
|
738
|
-
id: TerminalCommandId.AttachToSession,
|
|
739
|
-
title: ( localize2(16846, "Attach to Session")),
|
|
740
|
-
run: async (c, accessor) => {
|
|
741
|
-
const quickInputService = accessor.get(IQuickInputService);
|
|
742
|
-
const labelService = accessor.get(ILabelService);
|
|
743
|
-
const remoteAgentService = accessor.get(IRemoteAgentService);
|
|
744
|
-
const notificationService = accessor.get(INotificationService);
|
|
745
|
-
const remoteAuthority = remoteAgentService.getConnection()?.remoteAuthority ?? undefined;
|
|
746
|
-
const backend = await accessor.get(ITerminalInstanceService).getBackend(remoteAuthority);
|
|
747
|
-
if (!backend) {
|
|
748
|
-
throw ( new Error(`No backend registered for remote authority '${remoteAuthority}'`));
|
|
749
|
-
}
|
|
750
|
-
const terms = await backend.listProcesses();
|
|
751
|
-
backend.reduceConnectionGraceTime();
|
|
752
|
-
const unattachedTerms = terms.filter(term => !c.service.isAttachedToTerminal(term));
|
|
753
|
-
const items = ( unattachedTerms.map(term => {
|
|
754
|
-
const cwdLabel = labelService.getUriLabel(URI.file(term.cwd));
|
|
755
|
-
return {
|
|
756
|
-
label: term.title,
|
|
757
|
-
detail: term.workspaceName ? `${term.workspaceName} \u2E31 ${cwdLabel}` : cwdLabel,
|
|
758
|
-
description: term.pid ? String(term.pid) : "",
|
|
759
|
-
term
|
|
760
|
-
};
|
|
761
|
-
}));
|
|
762
|
-
if (items.length === 0) {
|
|
763
|
-
notificationService.info(( localize(16847, "There are no unattached terminals to attach to")));
|
|
764
|
-
return;
|
|
765
|
-
}
|
|
766
|
-
const selected = await quickInputService.pick(items, {
|
|
767
|
-
canPickMany: false
|
|
768
|
-
});
|
|
769
|
-
if (selected) {
|
|
770
|
-
const instance = await c.service.createTerminal({
|
|
771
|
-
config: {
|
|
772
|
-
attachPersistentProcess: selected.term
|
|
773
|
-
}
|
|
774
|
-
});
|
|
775
|
-
c.service.setActiveInstance(instance);
|
|
776
|
-
await focusActiveTerminal(instance, c);
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
});
|
|
780
|
-
registerActiveInstanceAction({
|
|
781
|
-
id: TerminalCommandId.ScrollToPreviousCommand,
|
|
782
|
-
title: terminalStrings.scrollToPreviousCommand,
|
|
783
|
-
keybinding: {
|
|
784
|
-
primary: KeyMod.CtrlCmd | KeyCode.UpArrow,
|
|
785
|
-
when: ( ContextKeyExpr.and(TerminalContextKeys.focus, ( CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()))),
|
|
786
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
787
|
-
},
|
|
788
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
789
|
-
icon: Codicon.arrowUp,
|
|
790
|
-
menu: [{
|
|
791
|
-
id: MenuId.ViewTitle,
|
|
792
|
-
group: "navigation",
|
|
793
|
-
order: 4,
|
|
794
|
-
when: ( ContextKeyExpr.equals("view", TERMINAL_VIEW_ID)),
|
|
795
|
-
isHiddenByDefault: true
|
|
796
|
-
}, ...( [MenuId.EditorTitle, MenuId.CompactWindowEditorTitle].map(id => ({
|
|
797
|
-
id,
|
|
798
|
-
group: "1_shellIntegration",
|
|
799
|
-
order: 4,
|
|
800
|
-
when: ( ResourceContextKey.Scheme.isEqualTo(Schemas.vscodeTerminal)),
|
|
801
|
-
isHiddenByDefault: true
|
|
802
|
-
})))],
|
|
803
|
-
run: activeInstance => activeInstance.xterm?.markTracker.scrollToPreviousMark(undefined, undefined, ( activeInstance.capabilities.has(TerminalCapability.CommandDetection)))
|
|
804
|
-
});
|
|
805
|
-
registerActiveInstanceAction({
|
|
806
|
-
id: TerminalCommandId.ScrollToNextCommand,
|
|
807
|
-
title: terminalStrings.scrollToNextCommand,
|
|
808
|
-
keybinding: {
|
|
809
|
-
primary: KeyMod.CtrlCmd | KeyCode.DownArrow,
|
|
810
|
-
when: ( ContextKeyExpr.and(TerminalContextKeys.focus, ( CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()))),
|
|
811
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
812
|
-
},
|
|
813
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
814
|
-
icon: Codicon.arrowDown,
|
|
815
|
-
menu: [{
|
|
816
|
-
id: MenuId.ViewTitle,
|
|
817
|
-
group: "navigation",
|
|
818
|
-
order: 5,
|
|
819
|
-
when: ( ContextKeyExpr.equals("view", TERMINAL_VIEW_ID)),
|
|
820
|
-
isHiddenByDefault: true
|
|
821
|
-
}, ...( [MenuId.EditorTitle, MenuId.CompactWindowEditorTitle].map(id => ({
|
|
822
|
-
id,
|
|
823
|
-
group: "1_shellIntegration",
|
|
824
|
-
order: 5,
|
|
825
|
-
when: ( ResourceContextKey.Scheme.isEqualTo(Schemas.vscodeTerminal)),
|
|
826
|
-
isHiddenByDefault: true
|
|
827
|
-
})))],
|
|
828
|
-
run: activeInstance => {
|
|
829
|
-
activeInstance.xterm?.markTracker.scrollToNextMark();
|
|
830
|
-
activeInstance.focus();
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
|
-
registerActiveInstanceAction({
|
|
834
|
-
id: TerminalCommandId.SelectToPreviousCommand,
|
|
835
|
-
title: ( localize2(16848, "Select to Previous Command")),
|
|
836
|
-
keybinding: {
|
|
837
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.UpArrow,
|
|
838
|
-
when: TerminalContextKeys.focus,
|
|
839
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
840
|
-
},
|
|
841
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
842
|
-
run: activeInstance => {
|
|
843
|
-
activeInstance.xterm?.markTracker.selectToPreviousMark();
|
|
844
|
-
activeInstance.focus();
|
|
845
|
-
}
|
|
846
|
-
});
|
|
847
|
-
registerActiveInstanceAction({
|
|
848
|
-
id: TerminalCommandId.SelectToNextCommand,
|
|
849
|
-
title: ( localize2(16849, "Select to Next Command")),
|
|
850
|
-
keybinding: {
|
|
851
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.DownArrow,
|
|
852
|
-
when: TerminalContextKeys.focus,
|
|
853
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
854
|
-
},
|
|
855
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
856
|
-
run: activeInstance => {
|
|
857
|
-
activeInstance.xterm?.markTracker.selectToNextMark();
|
|
858
|
-
activeInstance.focus();
|
|
859
|
-
}
|
|
860
|
-
});
|
|
861
|
-
registerActiveXtermAction({
|
|
862
|
-
id: TerminalCommandId.SelectToPreviousLine,
|
|
863
|
-
title: ( localize2(16850, "Select to Previous Line")),
|
|
864
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
865
|
-
run: async (xterm, _, instance) => {
|
|
866
|
-
xterm.markTracker.selectToPreviousLine();
|
|
867
|
-
(instance || xterm).focus();
|
|
868
|
-
}
|
|
869
|
-
});
|
|
870
|
-
registerActiveXtermAction({
|
|
871
|
-
id: TerminalCommandId.SelectToNextLine,
|
|
872
|
-
title: ( localize2(16851, "Select to Next Line")),
|
|
873
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
874
|
-
run: async (xterm, _, instance) => {
|
|
875
|
-
xterm.markTracker.selectToNextLine();
|
|
876
|
-
(instance || xterm).focus();
|
|
877
|
-
}
|
|
878
|
-
});
|
|
879
|
-
registerTerminalAction({
|
|
880
|
-
id: TerminalCommandId.NewWithCwd,
|
|
881
|
-
title: terminalStrings.newWithCwd,
|
|
882
|
-
metadata: {
|
|
883
|
-
description: terminalStrings.newWithCwd.value,
|
|
884
|
-
args: [{
|
|
885
|
-
name: "args",
|
|
886
|
-
schema: {
|
|
887
|
-
type: "object",
|
|
888
|
-
required: ["cwd"],
|
|
889
|
-
properties: {
|
|
890
|
-
cwd: {
|
|
891
|
-
description: ( localize(16852, "The directory to start the terminal at")),
|
|
892
|
-
type: "string"
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
}]
|
|
897
|
-
},
|
|
898
|
-
run: async (c, _, args) => {
|
|
899
|
-
const cwd = args ? toOptionalString(args.cwd) : undefined;
|
|
900
|
-
const instance = await c.service.createTerminal({
|
|
901
|
-
cwd
|
|
902
|
-
});
|
|
903
|
-
if (!instance) {
|
|
904
|
-
return;
|
|
905
|
-
}
|
|
906
|
-
c.service.setActiveInstance(instance);
|
|
907
|
-
await focusActiveTerminal(instance, c);
|
|
908
|
-
}
|
|
909
|
-
});
|
|
910
|
-
registerActiveInstanceAction({
|
|
911
|
-
id: TerminalCommandId.RenameWithArgs,
|
|
912
|
-
title: terminalStrings.renameWithArgs,
|
|
913
|
-
metadata: {
|
|
914
|
-
description: terminalStrings.renameWithArgs.value,
|
|
915
|
-
args: [{
|
|
916
|
-
name: "args",
|
|
917
|
-
schema: {
|
|
918
|
-
type: "object",
|
|
919
|
-
required: ["name"],
|
|
920
|
-
properties: {
|
|
921
|
-
name: {
|
|
922
|
-
description: ( localize(16853, "The new name for the terminal")),
|
|
923
|
-
type: "string",
|
|
924
|
-
minLength: 1
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
}]
|
|
929
|
-
},
|
|
930
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
931
|
-
f1: false,
|
|
932
|
-
run: async (activeInstance, c, accessor, args) => {
|
|
933
|
-
const notificationService = accessor.get(INotificationService);
|
|
934
|
-
const name = args ? toOptionalString(args.name) : undefined;
|
|
935
|
-
if (!name) {
|
|
936
|
-
notificationService.warn(( localize(16854, "No name argument provided")));
|
|
937
|
-
return;
|
|
938
|
-
}
|
|
939
|
-
activeInstance.rename(name);
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
registerActiveInstanceAction({
|
|
943
|
-
id: TerminalCommandId.Relaunch,
|
|
944
|
-
title: ( localize2(16855, "Relaunch Active Terminal")),
|
|
945
|
-
run: activeInstance => activeInstance.relaunch()
|
|
946
|
-
});
|
|
947
|
-
registerTerminalAction({
|
|
948
|
-
id: TerminalCommandId.Split,
|
|
949
|
-
title: terminalStrings.split,
|
|
950
|
-
precondition: ( ContextKeyExpr.or(
|
|
951
|
-
TerminalContextKeys.processSupported,
|
|
952
|
-
TerminalContextKeys.webExtensionContributedProfile
|
|
953
|
-
)),
|
|
954
|
-
keybinding: {
|
|
955
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Digit5,
|
|
956
|
-
weight: KeybindingWeight.WorkbenchContrib,
|
|
957
|
-
mac: {
|
|
958
|
-
primary: KeyMod.CtrlCmd | KeyCode.Backslash,
|
|
959
|
-
secondary: [KeyMod.WinCtrl | KeyMod.Shift | KeyCode.Digit5]
|
|
960
|
-
},
|
|
961
|
-
when: TerminalContextKeys.focus
|
|
962
|
-
},
|
|
963
|
-
icon: Codicon.splitHorizontal,
|
|
964
|
-
run: async (c, accessor, args) => {
|
|
965
|
-
const optionsOrProfile = isObject(args) ? args : undefined;
|
|
966
|
-
const commandService = accessor.get(ICommandService);
|
|
967
|
-
const workspaceContextService = accessor.get(IWorkspaceContextService);
|
|
968
|
-
const options = convertOptionsOrProfileToOptions(optionsOrProfile);
|
|
969
|
-
const activeInstance = (await c.service.getInstanceHost(options?.location)).activeInstance;
|
|
970
|
-
if (!activeInstance) {
|
|
971
|
-
return;
|
|
972
|
-
}
|
|
973
|
-
const cwd = await getCwdForSplit(
|
|
974
|
-
activeInstance,
|
|
975
|
-
workspaceContextService.getWorkspace().folders,
|
|
976
|
-
commandService,
|
|
977
|
-
c.configService
|
|
978
|
-
);
|
|
979
|
-
if (cwd === undefined) {
|
|
980
|
-
return;
|
|
981
|
-
}
|
|
982
|
-
const instance = await c.service.createTerminal({
|
|
983
|
-
location: {
|
|
984
|
-
parentTerminal: activeInstance
|
|
985
|
-
},
|
|
986
|
-
config: options?.config,
|
|
987
|
-
cwd
|
|
988
|
-
});
|
|
989
|
-
await focusActiveTerminal(instance, c);
|
|
990
|
-
}
|
|
991
|
-
});
|
|
992
|
-
registerTerminalAction({
|
|
993
|
-
id: TerminalCommandId.SplitActiveTab,
|
|
994
|
-
title: terminalStrings.split,
|
|
995
|
-
f1: false,
|
|
996
|
-
keybinding: {
|
|
997
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Digit5,
|
|
998
|
-
mac: {
|
|
999
|
-
primary: KeyMod.CtrlCmd | KeyCode.Backslash,
|
|
1000
|
-
secondary: [KeyMod.WinCtrl | KeyMod.Shift | KeyCode.Digit5]
|
|
1001
|
-
},
|
|
1002
|
-
weight: KeybindingWeight.WorkbenchContrib,
|
|
1003
|
-
when: TerminalContextKeys.tabsFocus
|
|
1004
|
-
},
|
|
1005
|
-
run: async (c, accessor) => {
|
|
1006
|
-
const instances = getSelectedViewInstances(accessor);
|
|
1007
|
-
if (instances) {
|
|
1008
|
-
const promises = [];
|
|
1009
|
-
for (const t of instances) {
|
|
1010
|
-
promises.push((async () => {
|
|
1011
|
-
await c.service.createTerminal({
|
|
1012
|
-
location: {
|
|
1013
|
-
parentTerminal: t
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
1016
|
-
await c.groupService.showPanel(true);
|
|
1017
|
-
})());
|
|
1018
|
-
}
|
|
1019
|
-
await Promise.all(promises);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
registerContextualInstanceAction({
|
|
1024
|
-
id: TerminalCommandId.Unsplit,
|
|
1025
|
-
title: terminalStrings.unsplit,
|
|
1026
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
1027
|
-
run: async (instance, c) => {
|
|
1028
|
-
const group = c.groupService.getGroupForInstance(instance);
|
|
1029
|
-
if (group && group?.terminalInstances.length > 1) {
|
|
1030
|
-
c.groupService.unsplitInstance(instance);
|
|
1031
|
-
}
|
|
1032
|
-
}
|
|
1033
|
-
});
|
|
1034
|
-
registerTerminalAction({
|
|
1035
|
-
id: TerminalCommandId.JoinActiveTab,
|
|
1036
|
-
title: ( localize2(16856, "Join Terminals")),
|
|
1037
|
-
precondition: ( ContextKeyExpr.and(sharedWhenClause.terminalAvailable, ( TerminalContextKeys.tabsSingularSelection.toNegated()))),
|
|
1038
|
-
run: async (c, accessor) => {
|
|
1039
|
-
const instances = getSelectedViewInstances(accessor);
|
|
1040
|
-
if (instances && instances.length > 1) {
|
|
1041
|
-
c.groupService.joinInstances(instances);
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
registerTerminalAction({
|
|
1046
|
-
id: TerminalCommandId.Join,
|
|
1047
|
-
title: ( localize2(16857, "Join Terminals...")),
|
|
1048
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
1049
|
-
run: async (c, accessor) => {
|
|
1050
|
-
const themeService = accessor.get(IThemeService);
|
|
1051
|
-
const notificationService = accessor.get(INotificationService);
|
|
1052
|
-
const quickInputService = accessor.get(IQuickInputService);
|
|
1053
|
-
const picks = [];
|
|
1054
|
-
if (c.groupService.instances.length <= 1) {
|
|
1055
|
-
notificationService.warn(( localize(16858, "Insufficient terminals for the join action")));
|
|
1056
|
-
return;
|
|
1057
|
-
}
|
|
1058
|
-
const otherInstances = c.groupService.instances.filter(i => i.instanceId !== c.groupService.activeInstance?.instanceId);
|
|
1059
|
-
for (const terminal of otherInstances) {
|
|
1060
|
-
const group = c.groupService.getGroupForInstance(terminal);
|
|
1061
|
-
if (group?.terminalInstances.length === 1) {
|
|
1062
|
-
const iconId = getIconId(accessor, terminal);
|
|
1063
|
-
const label = `$(${iconId}): ${terminal.title}`;
|
|
1064
|
-
const iconClasses = [];
|
|
1065
|
-
const colorClass = getColorClass(terminal);
|
|
1066
|
-
if (colorClass) {
|
|
1067
|
-
iconClasses.push(colorClass);
|
|
1068
|
-
}
|
|
1069
|
-
const uriClasses = getUriClasses(terminal, themeService.getColorTheme().type);
|
|
1070
|
-
if (uriClasses) {
|
|
1071
|
-
iconClasses.push(...uriClasses);
|
|
1072
|
-
}
|
|
1073
|
-
picks.push({
|
|
1074
|
-
terminal,
|
|
1075
|
-
label,
|
|
1076
|
-
iconClasses
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
|
-
}
|
|
1080
|
-
if (picks.length === 0) {
|
|
1081
|
-
notificationService.warn(( localize(16859, "All terminals are joined already")));
|
|
1082
|
-
return;
|
|
1083
|
-
}
|
|
1084
|
-
const result = await quickInputService.pick(picks, {});
|
|
1085
|
-
if (result) {
|
|
1086
|
-
c.groupService.joinInstances([result.terminal, c.groupService.activeInstance]);
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
});
|
|
1090
|
-
registerActiveInstanceAction({
|
|
1091
|
-
id: TerminalCommandId.SplitInActiveWorkspace,
|
|
1092
|
-
title: ( localize2(16860, "Split Terminal (In Active Workspace)")),
|
|
1093
|
-
run: async (instance, c) => {
|
|
1094
|
-
const newInstance = await c.service.createTerminal({
|
|
1095
|
-
location: {
|
|
1096
|
-
parentTerminal: instance
|
|
1097
|
-
}
|
|
1098
|
-
});
|
|
1099
|
-
if (newInstance?.target !== TerminalLocation.Editor) {
|
|
1100
|
-
await c.groupService.showPanel(true);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
});
|
|
1104
|
-
registerActiveXtermAction({
|
|
1105
|
-
id: TerminalCommandId.SelectAll,
|
|
1106
|
-
title: ( localize2(16861, "Select All")),
|
|
1107
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
1108
|
-
keybinding: [{
|
|
1109
|
-
primary: 0,
|
|
1110
|
-
mac: {
|
|
1111
|
-
primary: KeyMod.CtrlCmd | KeyCode.KeyA
|
|
1112
|
-
},
|
|
1113
|
-
weight: KeybindingWeight.WorkbenchContrib,
|
|
1114
|
-
when: TerminalContextKeys.focusInAny
|
|
1115
|
-
}],
|
|
1116
|
-
run: xterm => xterm.selectAll()
|
|
1117
|
-
});
|
|
1118
|
-
registerTerminalAction({
|
|
1119
|
-
id: TerminalCommandId.New,
|
|
1120
|
-
title: ( localize2(16862, "Create New Terminal")),
|
|
1121
|
-
precondition: ( ContextKeyExpr.or(
|
|
1122
|
-
TerminalContextKeys.processSupported,
|
|
1123
|
-
TerminalContextKeys.webExtensionContributedProfile
|
|
1124
|
-
)),
|
|
1125
|
-
icon: newTerminalIcon,
|
|
1126
|
-
keybinding: {
|
|
1127
|
-
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Backquote,
|
|
1128
|
-
mac: {
|
|
1129
|
-
primary: KeyMod.WinCtrl | KeyMod.Shift | KeyCode.Backquote
|
|
1130
|
-
},
|
|
1131
|
-
weight: KeybindingWeight.WorkbenchContrib
|
|
1132
|
-
},
|
|
1133
|
-
run: async (c, accessor, args) => {
|
|
1134
|
-
let eventOrOptions = isObject(args) ? args : undefined;
|
|
1135
|
-
const workspaceContextService = accessor.get(IWorkspaceContextService);
|
|
1136
|
-
const commandService = accessor.get(ICommandService);
|
|
1137
|
-
const editorGroupsService = accessor.get(IEditorGroupsService);
|
|
1138
|
-
const folders = workspaceContextService.getWorkspace().folders;
|
|
1139
|
-
if (eventOrOptions && isMouseEvent(eventOrOptions) && (eventOrOptions.altKey || eventOrOptions.ctrlKey)) {
|
|
1140
|
-
await c.service.createTerminal({
|
|
1141
|
-
location: {
|
|
1142
|
-
splitActiveTerminal: true
|
|
1143
|
-
}
|
|
1144
|
-
});
|
|
1145
|
-
return;
|
|
1146
|
-
}
|
|
1147
|
-
if (c.service.isProcessSupportRegistered) {
|
|
1148
|
-
eventOrOptions = !eventOrOptions || isMouseEvent(eventOrOptions) ? {} : eventOrOptions;
|
|
1149
|
-
if (isAuxiliaryWindow(getActiveWindow()) && !eventOrOptions.location) {
|
|
1150
|
-
eventOrOptions.location = {
|
|
1151
|
-
viewColumn: editorGroupToColumn(editorGroupsService, editorGroupsService.activeGroup)
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
let instance;
|
|
1155
|
-
if (folders.length <= 1) {
|
|
1156
|
-
instance = await c.service.createTerminal(eventOrOptions);
|
|
1157
|
-
} else {
|
|
1158
|
-
const cwd = (await pickTerminalCwd(accessor))?.cwd;
|
|
1159
|
-
if (!cwd) {
|
|
1160
|
-
return;
|
|
1161
|
-
}
|
|
1162
|
-
eventOrOptions.cwd = cwd;
|
|
1163
|
-
instance = await c.service.createTerminal(eventOrOptions);
|
|
1164
|
-
}
|
|
1165
|
-
c.service.setActiveInstance(instance);
|
|
1166
|
-
await focusActiveTerminal(instance, c);
|
|
1167
|
-
} else {
|
|
1168
|
-
if (c.profileService.contributedProfiles.length > 0) {
|
|
1169
|
-
commandService.executeCommand(TerminalCommandId.NewWithProfile);
|
|
1170
|
-
} else {
|
|
1171
|
-
commandService.executeCommand(TerminalCommandId.Toggle);
|
|
1172
|
-
}
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
});
|
|
1176
|
-
async function killInstance(c, instance) {
|
|
1177
|
-
if (!instance) {
|
|
1178
|
-
return;
|
|
1179
|
-
}
|
|
1180
|
-
await c.service.safeDisposeTerminal(instance);
|
|
1181
|
-
if (c.groupService.instances.length > 0) {
|
|
1182
|
-
await c.groupService.showPanel(true);
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
registerTerminalAction({
|
|
1186
|
-
id: TerminalCommandId.Kill,
|
|
1187
|
-
title: ( localize2(16863, "Kill the Active Terminal Instance")),
|
|
1188
|
-
precondition: ( ContextKeyExpr.or(sharedWhenClause.terminalAvailable, TerminalContextKeys.isOpen)),
|
|
1189
|
-
icon: killTerminalIcon,
|
|
1190
|
-
run: async c => killInstance(c, c.groupService.activeInstance)
|
|
1191
|
-
});
|
|
1192
|
-
registerTerminalAction({
|
|
1193
|
-
id: TerminalCommandId.KillViewOrEditor,
|
|
1194
|
-
title: terminalStrings.kill,
|
|
1195
|
-
f1: false,
|
|
1196
|
-
precondition: ( ContextKeyExpr.or(sharedWhenClause.terminalAvailable, TerminalContextKeys.isOpen)),
|
|
1197
|
-
run: async c => killInstance(c, c.service.activeInstance)
|
|
1198
|
-
});
|
|
1199
|
-
registerTerminalAction({
|
|
1200
|
-
id: TerminalCommandId.KillAll,
|
|
1201
|
-
title: ( localize2(16864, "Kill All Terminals")),
|
|
1202
|
-
precondition: ( ContextKeyExpr.or(sharedWhenClause.terminalAvailable, TerminalContextKeys.isOpen)),
|
|
1203
|
-
icon: Codicon.trash,
|
|
1204
|
-
run: async c => {
|
|
1205
|
-
const disposePromises = [];
|
|
1206
|
-
for (const instance of c.service.instances) {
|
|
1207
|
-
disposePromises.push(c.service.safeDisposeTerminal(instance));
|
|
1208
|
-
}
|
|
1209
|
-
await Promise.all(disposePromises);
|
|
1210
|
-
}
|
|
1211
|
-
});
|
|
1212
|
-
registerTerminalAction({
|
|
1213
|
-
id: TerminalCommandId.KillEditor,
|
|
1214
|
-
title: ( localize2(16865, "Kill the Active Terminal in Editor Area")),
|
|
1215
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
1216
|
-
keybinding: {
|
|
1217
|
-
primary: KeyMod.CtrlCmd | KeyCode.KeyW,
|
|
1218
|
-
win: {
|
|
1219
|
-
primary: KeyMod.CtrlCmd | KeyCode.F4,
|
|
1220
|
-
secondary: [KeyMod.CtrlCmd | KeyCode.KeyW]
|
|
1221
|
-
},
|
|
1222
|
-
weight: KeybindingWeight.WorkbenchContrib,
|
|
1223
|
-
when: ( ContextKeyExpr.and(TerminalContextKeys.focus, TerminalContextKeys.editorFocus))
|
|
1224
|
-
},
|
|
1225
|
-
run: (c, accessor) => accessor.get(ICommandService).executeCommand(CLOSE_EDITOR_COMMAND_ID)
|
|
1226
|
-
});
|
|
1227
|
-
registerTerminalAction({
|
|
1228
|
-
id: TerminalCommandId.KillActiveTab,
|
|
1229
|
-
title: terminalStrings.kill,
|
|
1230
|
-
f1: false,
|
|
1231
|
-
precondition: ( ContextKeyExpr.or(sharedWhenClause.terminalAvailable, TerminalContextKeys.isOpen)),
|
|
1232
|
-
keybinding: {
|
|
1233
|
-
primary: KeyCode.Delete,
|
|
1234
|
-
mac: {
|
|
1235
|
-
primary: KeyMod.CtrlCmd | KeyCode.Backspace,
|
|
1236
|
-
secondary: [KeyCode.Delete]
|
|
1237
|
-
},
|
|
1238
|
-
weight: KeybindingWeight.WorkbenchContrib,
|
|
1239
|
-
when: TerminalContextKeys.tabsFocus
|
|
1240
|
-
},
|
|
1241
|
-
run: async (c, accessor) => {
|
|
1242
|
-
const disposePromises = [];
|
|
1243
|
-
for (const terminal of getSelectedViewInstances(accessor) ?? []) {
|
|
1244
|
-
disposePromises.push(c.service.safeDisposeTerminal(terminal));
|
|
1245
|
-
}
|
|
1246
|
-
await Promise.all(disposePromises);
|
|
1247
|
-
c.groupService.focusTabs();
|
|
1248
|
-
}
|
|
1249
|
-
});
|
|
1250
|
-
registerTerminalAction({
|
|
1251
|
-
id: TerminalCommandId.FocusHover,
|
|
1252
|
-
title: terminalStrings.focusHover,
|
|
1253
|
-
precondition: ( ContextKeyExpr.or(sharedWhenClause.terminalAvailable, TerminalContextKeys.isOpen)),
|
|
1254
|
-
keybinding: {
|
|
1255
|
-
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KeyK, KeyMod.CtrlCmd | KeyCode.KeyI),
|
|
1256
|
-
weight: KeybindingWeight.WorkbenchContrib,
|
|
1257
|
-
when: ( ContextKeyExpr.or(TerminalContextKeys.tabsFocus, TerminalContextKeys.focus))
|
|
1258
|
-
},
|
|
1259
|
-
run: c => c.groupService.focusHover()
|
|
1260
|
-
});
|
|
1261
|
-
registerActiveInstanceAction({
|
|
1262
|
-
id: TerminalCommandId.Clear,
|
|
1263
|
-
title: ( localize2(16866, "Clear")),
|
|
1264
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
1265
|
-
keybinding: [{
|
|
1266
|
-
primary: 0,
|
|
1267
|
-
mac: {
|
|
1268
|
-
primary: KeyMod.CtrlCmd | KeyCode.KeyK
|
|
1269
|
-
},
|
|
1270
|
-
weight: KeybindingWeight.WorkbenchContrib + 1,
|
|
1271
|
-
when: ( ContextKeyExpr.or(( ContextKeyExpr.and(TerminalContextKeys.focus, ( CONTEXT_ACCESSIBILITY_MODE_ENABLED.negate()))), ( ContextKeyExpr.and(CONTEXT_ACCESSIBILITY_MODE_ENABLED, accessibleViewIsShown, ( accessibleViewCurrentProviderId.isEqualTo(AccessibleViewProviderId.Terminal))))))
|
|
1272
|
-
}],
|
|
1273
|
-
run: activeInstance => activeInstance.clearBuffer()
|
|
1274
|
-
});
|
|
1275
|
-
registerTerminalAction({
|
|
1276
|
-
id: TerminalCommandId.SelectDefaultProfile,
|
|
1277
|
-
title: ( localize2(16867, "Select Default Profile")),
|
|
1278
|
-
run: c => c.service.showProfileQuickPick("setDefault")
|
|
1279
|
-
});
|
|
1280
|
-
registerTerminalAction({
|
|
1281
|
-
id: TerminalCommandId.ConfigureTerminalSettings,
|
|
1282
|
-
title: ( localize2(16868, "Configure Terminal Settings")),
|
|
1283
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
1284
|
-
run: (c, accessor) => accessor.get(IPreferencesService).openSettings({
|
|
1285
|
-
jsonEditor: false,
|
|
1286
|
-
query: "@feature:terminal"
|
|
1287
|
-
})
|
|
1288
|
-
});
|
|
1289
|
-
registerActiveInstanceAction({
|
|
1290
|
-
id: TerminalCommandId.SetDimensions,
|
|
1291
|
-
title: ( localize2(16869, "Set Fixed Dimensions")),
|
|
1292
|
-
precondition: sharedWhenClause.terminalAvailable_and_opened,
|
|
1293
|
-
run: activeInstance => activeInstance.setFixedDimensions()
|
|
1294
|
-
});
|
|
1295
|
-
registerContextualInstanceAction({
|
|
1296
|
-
id: TerminalCommandId.SizeToContentWidth,
|
|
1297
|
-
title: terminalStrings.toggleSizeToContentWidth,
|
|
1298
|
-
precondition: sharedWhenClause.terminalAvailable_and_opened,
|
|
1299
|
-
keybinding: {
|
|
1300
|
-
primary: KeyMod.Alt | KeyCode.KeyZ,
|
|
1301
|
-
weight: KeybindingWeight.WorkbenchContrib,
|
|
1302
|
-
when: TerminalContextKeys.focus
|
|
1303
|
-
},
|
|
1304
|
-
run: instance => instance.toggleSizeToContentWidth()
|
|
1305
|
-
});
|
|
1306
|
-
registerTerminalAction({
|
|
1307
|
-
id: TerminalCommandId.SwitchTerminal,
|
|
1308
|
-
title: ( localize2(16870, "Switch Terminal")),
|
|
1309
|
-
precondition: sharedWhenClause.terminalAvailable,
|
|
1310
|
-
run: async (c, accessor, args) => {
|
|
1311
|
-
const item = toOptionalString(args);
|
|
1312
|
-
if (!item) {
|
|
1313
|
-
return;
|
|
1314
|
-
}
|
|
1315
|
-
if (item === SeparatorSelectOption.text) {
|
|
1316
|
-
c.service.refreshActiveGroup();
|
|
1317
|
-
return;
|
|
1318
|
-
}
|
|
1319
|
-
if (item === switchTerminalShowTabsTitle) {
|
|
1320
|
-
accessor.get(IConfigurationService).updateValue(TerminalSettingId.TabsEnabled, true);
|
|
1321
|
-
return;
|
|
1322
|
-
}
|
|
1323
|
-
const terminalIndexRe = /^([0-9]+): /;
|
|
1324
|
-
const indexMatches = terminalIndexRe.exec(item);
|
|
1325
|
-
if (indexMatches) {
|
|
1326
|
-
c.groupService.setActiveGroupByIndex(Number(indexMatches[1]) - 1);
|
|
1327
|
-
return c.groupService.showPanel(true);
|
|
1328
|
-
}
|
|
1329
|
-
const quickSelectProfiles = c.profileService.availableProfiles;
|
|
1330
|
-
const profileSelection = item.substring(4);
|
|
1331
|
-
if (quickSelectProfiles) {
|
|
1332
|
-
const profile = quickSelectProfiles.find(profile => profile.profileName === profileSelection);
|
|
1333
|
-
if (profile) {
|
|
1334
|
-
const instance = await c.service.createTerminal({
|
|
1335
|
-
config: profile
|
|
1336
|
-
});
|
|
1337
|
-
c.service.setActiveInstance(instance);
|
|
1338
|
-
} else {
|
|
1339
|
-
console.warn(`No profile with name "${profileSelection}"`);
|
|
1340
|
-
}
|
|
1341
|
-
} else {
|
|
1342
|
-
console.warn(`Unmatched terminal item: "${item}"`);
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
});
|
|
1346
|
-
}
|
|
1347
|
-
function getSelectedViewInstances2(accessor, args) {
|
|
1348
|
-
const terminalService = accessor.get(ITerminalService);
|
|
1349
|
-
const result = [];
|
|
1350
|
-
const context = parseActionArgs(args);
|
|
1351
|
-
if (context && context.length > 0) {
|
|
1352
|
-
for (const instanceContext of context) {
|
|
1353
|
-
const instance = terminalService.getInstanceFromId(instanceContext.instanceId);
|
|
1354
|
-
if (instance) {
|
|
1355
|
-
result.push(instance);
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
if (result.length > 0) {
|
|
1359
|
-
return result;
|
|
1360
|
-
}
|
|
1361
|
-
}
|
|
1362
|
-
return undefined;
|
|
1363
|
-
}
|
|
1364
|
-
function getSelectedViewInstances(accessor, args, args2) {
|
|
1365
|
-
const listService = accessor.get(IListService);
|
|
1366
|
-
const terminalGroupService = accessor.get(ITerminalGroupService);
|
|
1367
|
-
const result = [];
|
|
1368
|
-
const list = listService.lastFocusedList instanceof TerminalTabList ? listService.lastFocusedList : undefined;
|
|
1369
|
-
const selections = list?.getSelection();
|
|
1370
|
-
if (terminalGroupService.lastAccessedMenu === "inline-tab" && !selections?.length) {
|
|
1371
|
-
const instance = terminalGroupService.activeInstance;
|
|
1372
|
-
return instance ? [terminalGroupService.activeInstance] : undefined;
|
|
1373
|
-
}
|
|
1374
|
-
if (!list || !selections) {
|
|
1375
|
-
return undefined;
|
|
1376
|
-
}
|
|
1377
|
-
const focused = list.getFocus();
|
|
1378
|
-
const viewInstances = terminalGroupService.instances;
|
|
1379
|
-
if (focused.length === 1 && !selections.includes(focused[0])) {
|
|
1380
|
-
result.push(viewInstances[focused[0]]);
|
|
1381
|
-
return result;
|
|
1382
|
-
}
|
|
1383
|
-
for (const selection of selections) {
|
|
1384
|
-
result.push(viewInstances[selection]);
|
|
1385
|
-
}
|
|
1386
|
-
return result.filter(r => !!r);
|
|
1387
|
-
}
|
|
1388
|
-
function validateTerminalName(name) {
|
|
1389
|
-
if (!name || name.trim().length === 0) {
|
|
1390
|
-
return {
|
|
1391
|
-
content: ( localize(16871, "Providing no name will reset it to the default value")),
|
|
1392
|
-
severity: Severity.Info
|
|
1393
|
-
};
|
|
1394
|
-
}
|
|
1395
|
-
return null;
|
|
1396
|
-
}
|
|
1397
|
-
function isTerminalProfile(obj) {
|
|
1398
|
-
return isObject(obj) && "profileName" in obj;
|
|
1399
|
-
}
|
|
1400
|
-
function convertOptionsOrProfileToOptions(optionsOrProfile) {
|
|
1401
|
-
if (isTerminalProfile(optionsOrProfile)) {
|
|
1402
|
-
return {
|
|
1403
|
-
config: optionsOrProfile,
|
|
1404
|
-
location: optionsOrProfile.location
|
|
1405
|
-
};
|
|
1406
|
-
}
|
|
1407
|
-
return optionsOrProfile;
|
|
1408
|
-
}
|
|
1409
|
-
let newWithProfileAction;
|
|
1410
|
-
function refreshTerminalActions(detectedProfiles) {
|
|
1411
|
-
const profileEnum = createProfileSchemaEnums(detectedProfiles);
|
|
1412
|
-
newWithProfileAction?.dispose();
|
|
1413
|
-
newWithProfileAction = registerAction2(class extends Action2 {
|
|
1414
|
-
constructor() {
|
|
1415
|
-
super({
|
|
1416
|
-
id: TerminalCommandId.NewWithProfile,
|
|
1417
|
-
title: ( localize2(16872, "Create New Terminal (With Profile)")),
|
|
1418
|
-
f1: true,
|
|
1419
|
-
precondition: ( ContextKeyExpr.or(
|
|
1420
|
-
TerminalContextKeys.processSupported,
|
|
1421
|
-
TerminalContextKeys.webExtensionContributedProfile
|
|
1422
|
-
)),
|
|
1423
|
-
metadata: {
|
|
1424
|
-
description: TerminalCommandId.NewWithProfile,
|
|
1425
|
-
args: [{
|
|
1426
|
-
name: "args",
|
|
1427
|
-
schema: {
|
|
1428
|
-
type: "object",
|
|
1429
|
-
required: ["profileName"],
|
|
1430
|
-
properties: {
|
|
1431
|
-
profileName: {
|
|
1432
|
-
description: ( localize(16873, "The name of the profile to create")),
|
|
1433
|
-
type: "string",
|
|
1434
|
-
enum: profileEnum.values,
|
|
1435
|
-
markdownEnumDescriptions: profileEnum.markdownDescriptions
|
|
1436
|
-
},
|
|
1437
|
-
location: {
|
|
1438
|
-
description: ( localize(16874, "Where to create the terminal")),
|
|
1439
|
-
type: "string",
|
|
1440
|
-
enum: ["view", "editor"],
|
|
1441
|
-
enumDescriptions: [( localize(16875, "Create the terminal in the terminal view")), ( localize(16876, "Create the terminal in the editor"))]
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
}]
|
|
1446
|
-
}
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1449
|
-
async run(accessor, eventOrOptionsOrProfile, profile) {
|
|
1450
|
-
const c = getTerminalServices(accessor);
|
|
1451
|
-
const workspaceContextService = accessor.get(IWorkspaceContextService);
|
|
1452
|
-
const commandService = accessor.get(ICommandService);
|
|
1453
|
-
let event;
|
|
1454
|
-
let options;
|
|
1455
|
-
let instance;
|
|
1456
|
-
let cwd;
|
|
1457
|
-
if (isObject(eventOrOptionsOrProfile) && eventOrOptionsOrProfile && hasKey(eventOrOptionsOrProfile, {
|
|
1458
|
-
profileName: true
|
|
1459
|
-
})) {
|
|
1460
|
-
const config = c.profileService.availableProfiles.find(profile => profile.profileName === eventOrOptionsOrProfile.profileName);
|
|
1461
|
-
if (!config) {
|
|
1462
|
-
throw ( new Error(`Could not find terminal profile "${eventOrOptionsOrProfile.profileName}"`));
|
|
1463
|
-
}
|
|
1464
|
-
options = {
|
|
1465
|
-
config
|
|
1466
|
-
};
|
|
1467
|
-
function isSimpleArgs(obj) {
|
|
1468
|
-
return isObject(obj) && "location" in obj;
|
|
1469
|
-
}
|
|
1470
|
-
if (isSimpleArgs(eventOrOptionsOrProfile)) {
|
|
1471
|
-
switch (eventOrOptionsOrProfile.location) {
|
|
1472
|
-
case "editor":
|
|
1473
|
-
options.location = TerminalLocation.Editor;
|
|
1474
|
-
break;
|
|
1475
|
-
case "view":
|
|
1476
|
-
options.location = TerminalLocation.Panel;
|
|
1477
|
-
break;
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
} else if (isMouseEvent(eventOrOptionsOrProfile) || isPointerEvent(eventOrOptionsOrProfile) || isKeyboardEvent(eventOrOptionsOrProfile)) {
|
|
1481
|
-
event = eventOrOptionsOrProfile;
|
|
1482
|
-
options = profile ? {
|
|
1483
|
-
config: profile
|
|
1484
|
-
} : undefined;
|
|
1485
|
-
} else {
|
|
1486
|
-
options = convertOptionsOrProfileToOptions(eventOrOptionsOrProfile);
|
|
1487
|
-
}
|
|
1488
|
-
if (event && (event.altKey || event.ctrlKey)) {
|
|
1489
|
-
const parentTerminal = c.service.activeInstance;
|
|
1490
|
-
if (parentTerminal) {
|
|
1491
|
-
await c.service.createTerminal({
|
|
1492
|
-
location: {
|
|
1493
|
-
parentTerminal
|
|
1494
|
-
},
|
|
1495
|
-
config: options?.config
|
|
1496
|
-
});
|
|
1497
|
-
return;
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
const folders = workspaceContextService.getWorkspace().folders;
|
|
1501
|
-
if (folders.length > 1) {
|
|
1502
|
-
const options = {
|
|
1503
|
-
placeHolder: ( localize(16821, "Select current working directory for new terminal"))
|
|
1504
|
-
};
|
|
1505
|
-
const workspace = await commandService.executeCommand(PICK_WORKSPACE_FOLDER_COMMAND_ID, [options]);
|
|
1506
|
-
if (!workspace) {
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1509
|
-
cwd = workspace.uri;
|
|
1510
|
-
}
|
|
1511
|
-
if (options) {
|
|
1512
|
-
options.cwd = cwd;
|
|
1513
|
-
instance = await c.service.createTerminal(options);
|
|
1514
|
-
} else {
|
|
1515
|
-
instance = await c.service.showProfileQuickPick("createInstance", cwd);
|
|
1516
|
-
}
|
|
1517
|
-
if (instance) {
|
|
1518
|
-
c.service.setActiveInstance(instance);
|
|
1519
|
-
await focusActiveTerminal(instance, c);
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
});
|
|
1523
|
-
return newWithProfileAction;
|
|
1524
|
-
}
|
|
1525
|
-
function getResourceOrActiveInstance(c, resource) {
|
|
1526
|
-
return c.service.getInstanceFromResource(toOptionalUri(resource)) || c.service.activeInstance;
|
|
1527
|
-
}
|
|
1528
|
-
async function pickTerminalCwd(accessor, cancel) {
|
|
1529
|
-
const quickInputService = accessor.get(IQuickInputService);
|
|
1530
|
-
const labelService = accessor.get(ILabelService);
|
|
1531
|
-
const contextService = accessor.get(IWorkspaceContextService);
|
|
1532
|
-
const modelService = accessor.get(IModelService);
|
|
1533
|
-
const languageService = accessor.get(ILanguageService);
|
|
1534
|
-
const configurationService = accessor.get(IConfigurationService);
|
|
1535
|
-
const configurationResolverService = accessor.get(IConfigurationResolverService);
|
|
1536
|
-
const folders = contextService.getWorkspace().folders;
|
|
1537
|
-
if (!folders.length) {
|
|
1538
|
-
return;
|
|
1539
|
-
}
|
|
1540
|
-
const folderCwdPairs = await Promise.all(( folders.map(
|
|
1541
|
-
e => resolveWorkspaceFolderCwd(e, configurationService, configurationResolverService)
|
|
1542
|
-
)));
|
|
1543
|
-
const shrinkedPairs = shrinkWorkspaceFolderCwdPairs(folderCwdPairs);
|
|
1544
|
-
if (shrinkedPairs.length === 1) {
|
|
1545
|
-
return shrinkedPairs[0];
|
|
1546
|
-
}
|
|
1547
|
-
const folderPicks = ( shrinkedPairs.map(pair => {
|
|
1548
|
-
const label = pair.folder.name;
|
|
1549
|
-
const description = pair.isOverridden ? ( localize(16877, "(Overridden) {0}", labelService.getUriLabel(pair.cwd, {
|
|
1550
|
-
relative: !pair.isAbsolute
|
|
1551
|
-
}))) : labelService.getUriLabel(dirname(pair.cwd), {
|
|
1552
|
-
relative: true
|
|
1553
|
-
});
|
|
1554
|
-
return {
|
|
1555
|
-
label,
|
|
1556
|
-
description: description !== label ? description : undefined,
|
|
1557
|
-
pair: pair,
|
|
1558
|
-
iconClasses: getIconClasses(modelService, languageService, pair.cwd, FileKind.ROOT_FOLDER)
|
|
1559
|
-
};
|
|
1560
|
-
}));
|
|
1561
|
-
const options = {
|
|
1562
|
-
placeHolder: ( localize(16821, "Select current working directory for new terminal")),
|
|
1563
|
-
matchOnDescription: true,
|
|
1564
|
-
canPickMany: false
|
|
1565
|
-
};
|
|
1566
|
-
const token = CancellationToken.None;
|
|
1567
|
-
const pick = await quickInputService.pick(folderPicks, options, token);
|
|
1568
|
-
return pick?.pair;
|
|
1569
|
-
}
|
|
1570
|
-
async function resolveWorkspaceFolderCwd(folder, configurationService, configurationResolverService) {
|
|
1571
|
-
const cwdConfig = configurationService.getValue(TerminalSettingId.Cwd, {
|
|
1572
|
-
resource: folder.uri
|
|
1573
|
-
});
|
|
1574
|
-
if (!isString(cwdConfig) || cwdConfig.length === 0) {
|
|
1575
|
-
return {
|
|
1576
|
-
folder,
|
|
1577
|
-
cwd: folder.uri,
|
|
1578
|
-
isAbsolute: false,
|
|
1579
|
-
isOverridden: false
|
|
1580
|
-
};
|
|
1581
|
-
}
|
|
1582
|
-
const resolvedCwdConfig = await configurationResolverService.resolveAsync(folder, cwdConfig);
|
|
1583
|
-
return isAbsolute(resolvedCwdConfig) || resolvedCwdConfig.startsWith(ConfigurationResolverExpression.VARIABLE_LHS) ? {
|
|
1584
|
-
folder,
|
|
1585
|
-
isAbsolute: true,
|
|
1586
|
-
isOverridden: true,
|
|
1587
|
-
cwd: ( URI.from({
|
|
1588
|
-
...folder.uri,
|
|
1589
|
-
path: resolvedCwdConfig
|
|
1590
|
-
}))
|
|
1591
|
-
} : {
|
|
1592
|
-
folder,
|
|
1593
|
-
isAbsolute: false,
|
|
1594
|
-
isOverridden: true,
|
|
1595
|
-
cwd: URI.joinPath(folder.uri, resolvedCwdConfig)
|
|
1596
|
-
};
|
|
1597
|
-
}
|
|
1598
|
-
function shrinkWorkspaceFolderCwdPairs(pairs) {
|
|
1599
|
-
const map = ( new Map());
|
|
1600
|
-
for (const pair of pairs) {
|
|
1601
|
-
const key = ( pair.cwd.toString());
|
|
1602
|
-
const value = map.get(key);
|
|
1603
|
-
if (!value || key === ( pair.folder.uri.toString())) {
|
|
1604
|
-
map.set(key, pair);
|
|
1605
|
-
}
|
|
1606
|
-
}
|
|
1607
|
-
const selectedPairs = ( new Set(( map.values())));
|
|
1608
|
-
const selectedPairsInOrder = pairs.filter(x => ( selectedPairs.has(x)));
|
|
1609
|
-
return selectedPairsInOrder;
|
|
1610
|
-
}
|
|
1611
|
-
async function focusActiveTerminal(instance, c) {
|
|
1612
|
-
const target = instance ?? c.service.activeInstance ?? c.editorService.activeInstance ?? c.groupService.activeInstance;
|
|
1613
|
-
if (!target) {
|
|
1614
|
-
if (c.groupService.instances.length > 0) {
|
|
1615
|
-
await c.groupService.showPanel(true);
|
|
1616
|
-
}
|
|
1617
|
-
return;
|
|
1618
|
-
}
|
|
1619
|
-
await c.service.focusInstance(target);
|
|
1620
|
-
}
|
|
1621
|
-
async function renameWithQuickPick(c, accessor, resource) {
|
|
1622
|
-
let instance = resource;
|
|
1623
|
-
if (!instance || !instance?.rename) {
|
|
1624
|
-
instance = getResourceOrActiveInstance(c, resource);
|
|
1625
|
-
}
|
|
1626
|
-
if (instance) {
|
|
1627
|
-
const title = await accessor.get(IQuickInputService).input({
|
|
1628
|
-
value: instance.title,
|
|
1629
|
-
prompt: ( localize(16878, "Enter terminal name"))
|
|
1630
|
-
});
|
|
1631
|
-
if (title) {
|
|
1632
|
-
instance.rename(title);
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
function toOptionalUri(obj) {
|
|
1637
|
-
return URI.isUri(obj) ? obj : undefined;
|
|
1638
|
-
}
|
|
1639
|
-
function toOptionalString(obj) {
|
|
1640
|
-
return isString(obj) ? obj : undefined;
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
export { TerminalLaunchHelpAction, getCwdForSplit, refreshTerminalActions, registerActiveInstanceAction, registerActiveXtermAction, registerContextualInstanceAction, registerTerminalAction, registerTerminalActions, sharedWhenClause, shrinkWorkspaceFolderCwdPairs, switchTerminalShowTabsTitle, validateTerminalName };
|