@codingame/monaco-vscode-xterm-addons-common 24.1.0
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/empty.js +1 -0
- package/package.json +51 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.d.ts +25 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +315 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.d.ts +49 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatPasteProviders.js +379 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.d.ts +17 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +101 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +201 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.d.ts +7 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +79 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.d.ts +8 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +145 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +73 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +468 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.d.ts +18 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.js +48 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.d.ts +80 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +583 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.d.ts +64 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +582 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermAddonImporter.d.ts +25 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermAddonImporter.js +43 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +187 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +867 -0
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
|
|
2
|
+
import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
|
|
3
|
+
import { addDisposableListener, EventType } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
4
|
+
import { Separator } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
|
|
5
|
+
import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
6
|
+
import { Disposable, DisposableMap, toDisposable, DisposableStore, dispose } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
7
|
+
import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
|
|
8
|
+
import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
|
|
9
|
+
import { AccessibilitySignal } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
|
|
10
|
+
import { IAccessibilitySignalService } from '@codingame/monaco-vscode-api/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService.service';
|
|
11
|
+
import { IClipboardService } from '@codingame/monaco-vscode-api/vscode/vs/platform/clipboard/common/clipboardService.service';
|
|
12
|
+
import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
|
|
13
|
+
import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
|
|
14
|
+
import { IContextMenuService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service';
|
|
15
|
+
import '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification';
|
|
16
|
+
import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
|
|
17
|
+
import { IOpenerService } from '@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service';
|
|
18
|
+
import { IQuickInputService } from '@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
19
|
+
import { TerminalCapability, CommandInvalidationReason } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities';
|
|
20
|
+
import { TerminalSettingId } from '@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/terminal';
|
|
21
|
+
import { IThemeService } from '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service';
|
|
22
|
+
import { terminalDecorationMark } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminalIcons';
|
|
23
|
+
import { DecorationSelector, updateLayout, getTerminalDecorationHoverContent, getTerminalCommandDecorationState } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/xterm/decorationStyles';
|
|
24
|
+
import { TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR, TERMINAL_COMMAND_DECORATION_ERROR_BACKGROUND_COLOR, TERMINAL_COMMAND_DECORATION_SUCCESS_BACKGROUND_COLOR } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/common/terminalColorRegistry';
|
|
25
|
+
import { ILifecycleService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
26
|
+
import { IHoverService } from '@codingame/monaco-vscode-api/vscode/vs/platform/hover/browser/hover.service';
|
|
27
|
+
import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
|
|
28
|
+
import { IChatContextPickService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chatContextPickService.service';
|
|
29
|
+
import { IChatWidgetService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/chat.service';
|
|
30
|
+
import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
|
|
31
|
+
import { TerminalContext } from '../../../chat/browser/actions/chatContext.js';
|
|
32
|
+
import { parseTerminalUri, getTerminalUri } from '../terminalUri.js';
|
|
33
|
+
import { ChatAgentLocation } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/constants';
|
|
34
|
+
import { isString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
|
|
35
|
+
import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severity';
|
|
36
|
+
|
|
37
|
+
let DecorationAddon = class DecorationAddon extends Disposable {
|
|
38
|
+
constructor(_resource, _capabilities, _clipboardService, _contextMenuService, _configurationService, _themeService, _openerService, _quickInputService, lifecycleService, _commandService, _accessibilitySignalService, _notificationService, _hoverService, _contextPickService, _chatWidgetService, _instantiationService) {
|
|
39
|
+
super();
|
|
40
|
+
this._resource = _resource;
|
|
41
|
+
this._capabilities = _capabilities;
|
|
42
|
+
this._clipboardService = _clipboardService;
|
|
43
|
+
this._contextMenuService = _contextMenuService;
|
|
44
|
+
this._configurationService = _configurationService;
|
|
45
|
+
this._themeService = _themeService;
|
|
46
|
+
this._openerService = _openerService;
|
|
47
|
+
this._quickInputService = _quickInputService;
|
|
48
|
+
this._commandService = _commandService;
|
|
49
|
+
this._accessibilitySignalService = _accessibilitySignalService;
|
|
50
|
+
this._notificationService = _notificationService;
|
|
51
|
+
this._hoverService = _hoverService;
|
|
52
|
+
this._contextPickService = _contextPickService;
|
|
53
|
+
this._chatWidgetService = _chatWidgetService;
|
|
54
|
+
this._instantiationService = _instantiationService;
|
|
55
|
+
this._capabilityDisposables = this._register(( new DisposableMap()));
|
|
56
|
+
this._decorations = ( new Map());
|
|
57
|
+
this._registeredMenuItems = ( new Map());
|
|
58
|
+
this._onDidRequestRunCommand = this._register(( new Emitter()));
|
|
59
|
+
this.onDidRequestRunCommand = this._onDidRequestRunCommand.event;
|
|
60
|
+
this._onDidRequestCopyAsHtml = this._register(( new Emitter()));
|
|
61
|
+
this.onDidRequestCopyAsHtml = this._onDidRequestCopyAsHtml.event;
|
|
62
|
+
this._register(toDisposable(() => this._dispose()));
|
|
63
|
+
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
|
64
|
+
if (e.affectsConfiguration(TerminalSettingId.FontSize) || e.affectsConfiguration(TerminalSettingId.LineHeight)) {
|
|
65
|
+
this.refreshLayouts();
|
|
66
|
+
}
|
|
67
|
+
else if (e.affectsConfiguration('workbench.colorCustomizations')) {
|
|
68
|
+
this._refreshStyles(true);
|
|
69
|
+
}
|
|
70
|
+
else if (e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationsEnabled)) {
|
|
71
|
+
this._removeCapabilityDisposables(TerminalCapability.CommandDetection);
|
|
72
|
+
this._updateDecorationVisibility();
|
|
73
|
+
}
|
|
74
|
+
}));
|
|
75
|
+
this._register(this._themeService.onDidColorThemeChange(() => this._refreshStyles(true)));
|
|
76
|
+
this._updateDecorationVisibility();
|
|
77
|
+
this._register(this._capabilities.onDidAddCapability(c => this._createCapabilityDisposables(c.id)));
|
|
78
|
+
this._register(this._capabilities.onDidRemoveCapability(c => this._removeCapabilityDisposables(c.id)));
|
|
79
|
+
this._register(lifecycleService.onWillShutdown(() => this._disposeAllDecorations()));
|
|
80
|
+
}
|
|
81
|
+
_createCapabilityDisposables(c) {
|
|
82
|
+
const capability = this._capabilities.get(c);
|
|
83
|
+
if (!capability || ( this._capabilityDisposables.has(c))) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const store = ( new DisposableStore());
|
|
87
|
+
switch (capability.type) {
|
|
88
|
+
case TerminalCapability.BufferMarkDetection:
|
|
89
|
+
store.add(capability.onMarkAdded(mark => this.registerMarkDecoration(mark)));
|
|
90
|
+
break;
|
|
91
|
+
case TerminalCapability.CommandDetection: {
|
|
92
|
+
const disposables = this._getCommandDetectionListeners(capability);
|
|
93
|
+
for (const d of disposables) {
|
|
94
|
+
store.add(d);
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this._capabilityDisposables.set(c, store);
|
|
100
|
+
}
|
|
101
|
+
_removeCapabilityDisposables(c) {
|
|
102
|
+
this._capabilityDisposables.deleteAndDispose(c);
|
|
103
|
+
}
|
|
104
|
+
registerMarkDecoration(mark) {
|
|
105
|
+
if (!this._terminal || (!this._showGutterDecorations && !this._showOverviewRulerDecorations)) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
if (mark.hidden) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
return this.registerCommandDecoration(undefined, undefined, mark);
|
|
112
|
+
}
|
|
113
|
+
_updateDecorationVisibility() {
|
|
114
|
+
const showDecorations = this._configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationsEnabled);
|
|
115
|
+
this._showGutterDecorations = (showDecorations === 'both' || showDecorations === 'gutter');
|
|
116
|
+
this._showOverviewRulerDecorations = (showDecorations === 'both' || showDecorations === 'overviewRuler');
|
|
117
|
+
this._disposeAllDecorations();
|
|
118
|
+
if (this._showGutterDecorations || this._showOverviewRulerDecorations) {
|
|
119
|
+
this._attachToCommandCapability();
|
|
120
|
+
this._updateGutterDecorationVisibility();
|
|
121
|
+
}
|
|
122
|
+
const currentCommand = this._capabilities.get(TerminalCapability.CommandDetection)?.executingCommandObject;
|
|
123
|
+
if (currentCommand) {
|
|
124
|
+
this.registerCommandDecoration(currentCommand, true);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
_disposeAllDecorations() {
|
|
128
|
+
this._placeholderDecoration?.dispose();
|
|
129
|
+
for (const value of ( this._decorations.values())) {
|
|
130
|
+
value.decoration.dispose();
|
|
131
|
+
dispose(value.disposables);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
_updateGutterDecorationVisibility() {
|
|
135
|
+
const commandDecorationElements = this._terminal?.element?.querySelectorAll(DecorationSelector.CommandDecoration);
|
|
136
|
+
if (commandDecorationElements) {
|
|
137
|
+
for (const commandDecorationElement of commandDecorationElements) {
|
|
138
|
+
this._updateCommandDecorationVisibility(commandDecorationElement);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
_updateCommandDecorationVisibility(commandDecorationElement) {
|
|
143
|
+
if (this._showGutterDecorations) {
|
|
144
|
+
commandDecorationElement.classList.remove(DecorationSelector.Hide);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
commandDecorationElement.classList.add(DecorationSelector.Hide);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
refreshLayouts() {
|
|
151
|
+
updateLayout(this._configurationService, this._placeholderDecoration?.element);
|
|
152
|
+
for (const decoration of this._decorations) {
|
|
153
|
+
updateLayout(this._configurationService, decoration[1].decoration.element);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
_refreshStyles(refreshOverviewRulerColors) {
|
|
157
|
+
if (refreshOverviewRulerColors) {
|
|
158
|
+
for (const decoration of ( this._decorations.values())) {
|
|
159
|
+
const color = this._getDecorationCssColor(decoration.command)?.toString() ?? '';
|
|
160
|
+
if (decoration.decoration.options?.overviewRulerOptions) {
|
|
161
|
+
decoration.decoration.options.overviewRulerOptions.color = color;
|
|
162
|
+
}
|
|
163
|
+
else if (decoration.decoration.options) {
|
|
164
|
+
decoration.decoration.options.overviewRulerOptions = { color };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
this._updateClasses(this._placeholderDecoration?.element);
|
|
169
|
+
for (const decoration of ( this._decorations.values())) {
|
|
170
|
+
this._updateClasses(decoration.decoration.element, decoration.command, decoration.markProperties);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
_dispose() {
|
|
174
|
+
for (const disposable of ( this._capabilityDisposables.values())) {
|
|
175
|
+
dispose(disposable);
|
|
176
|
+
}
|
|
177
|
+
this.clearDecorations();
|
|
178
|
+
}
|
|
179
|
+
_clearPlaceholder() {
|
|
180
|
+
this._placeholderDecoration?.dispose();
|
|
181
|
+
this._placeholderDecoration = undefined;
|
|
182
|
+
}
|
|
183
|
+
clearDecorations() {
|
|
184
|
+
this._placeholderDecoration?.marker.dispose();
|
|
185
|
+
this._clearPlaceholder();
|
|
186
|
+
this._disposeAllDecorations();
|
|
187
|
+
this._decorations.clear();
|
|
188
|
+
}
|
|
189
|
+
_attachToCommandCapability() {
|
|
190
|
+
if (( this._capabilities.has(TerminalCapability.CommandDetection))) {
|
|
191
|
+
const capability = this._capabilities.get(TerminalCapability.CommandDetection);
|
|
192
|
+
const disposables = this._getCommandDetectionListeners(capability);
|
|
193
|
+
const store = ( new DisposableStore());
|
|
194
|
+
for (const d of disposables) {
|
|
195
|
+
store.add(d);
|
|
196
|
+
}
|
|
197
|
+
this._capabilityDisposables.set(TerminalCapability.CommandDetection, store);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
_getCommandDetectionListeners(capability) {
|
|
201
|
+
this._removeCapabilityDisposables(TerminalCapability.CommandDetection);
|
|
202
|
+
const commandDetectionListeners = [];
|
|
203
|
+
if (capability.executingCommandObject?.marker) {
|
|
204
|
+
this.registerCommandDecoration(capability.executingCommandObject, true);
|
|
205
|
+
}
|
|
206
|
+
commandDetectionListeners.push(capability.onCommandStarted(command => this.registerCommandDecoration(command, true)));
|
|
207
|
+
for (const command of capability.commands) {
|
|
208
|
+
this.registerCommandDecoration(command);
|
|
209
|
+
}
|
|
210
|
+
commandDetectionListeners.push(capability.onCommandFinished(command => {
|
|
211
|
+
const buffer = this._terminal?.buffer?.active;
|
|
212
|
+
const marker = command.promptStartMarker;
|
|
213
|
+
const shouldRegisterDecoration = (command.exitCode === undefined ||
|
|
214
|
+
(buffer && marker && buffer.baseY + buffer.cursorY >= marker.line));
|
|
215
|
+
if (shouldRegisterDecoration) {
|
|
216
|
+
this.registerCommandDecoration(command);
|
|
217
|
+
}
|
|
218
|
+
if (command.exitCode) {
|
|
219
|
+
this._accessibilitySignalService.playSignal(AccessibilitySignal.terminalCommandFailed);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
this._accessibilitySignalService.playSignal(AccessibilitySignal.terminalCommandSucceeded);
|
|
223
|
+
}
|
|
224
|
+
}));
|
|
225
|
+
commandDetectionListeners.push(capability.onCommandInvalidated(commands => {
|
|
226
|
+
for (const command of commands) {
|
|
227
|
+
const id = command.marker?.id;
|
|
228
|
+
if (id) {
|
|
229
|
+
const match = this._decorations.get(id);
|
|
230
|
+
if (match) {
|
|
231
|
+
match.decoration.dispose();
|
|
232
|
+
dispose(match.disposables);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}));
|
|
237
|
+
commandDetectionListeners.push(capability.onCurrentCommandInvalidated((request) => {
|
|
238
|
+
if (request.reason === CommandInvalidationReason.NoProblemsReported) {
|
|
239
|
+
const lastDecoration = Array.from(this._decorations.entries())[this._decorations.size - 1];
|
|
240
|
+
lastDecoration?.[1].decoration.dispose();
|
|
241
|
+
}
|
|
242
|
+
else if (request.reason === CommandInvalidationReason.Windows) {
|
|
243
|
+
this._clearPlaceholder();
|
|
244
|
+
}
|
|
245
|
+
}));
|
|
246
|
+
return commandDetectionListeners;
|
|
247
|
+
}
|
|
248
|
+
activate(terminal) {
|
|
249
|
+
this._terminal = terminal;
|
|
250
|
+
this._attachToCommandCapability();
|
|
251
|
+
}
|
|
252
|
+
registerCommandDecoration(command, beforeCommandExecution, markProperties) {
|
|
253
|
+
if (!this._terminal || (beforeCommandExecution && !command) || (!this._showGutterDecorations && !this._showOverviewRulerDecorations)) {
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
const marker = command?.marker || markProperties?.marker;
|
|
257
|
+
if (!marker) {
|
|
258
|
+
throw ( new Error(
|
|
259
|
+
`cannot add a decoration for a command ${JSON.stringify(command)} with no marker`
|
|
260
|
+
));
|
|
261
|
+
}
|
|
262
|
+
this._clearPlaceholder();
|
|
263
|
+
const color = this._getDecorationCssColor(command)?.toString() ?? '';
|
|
264
|
+
const decoration = this._terminal.registerDecoration({
|
|
265
|
+
marker,
|
|
266
|
+
overviewRulerOptions: this._showOverviewRulerDecorations ? (beforeCommandExecution
|
|
267
|
+
? { color, position: 'left' }
|
|
268
|
+
: { color, position: command?.exitCode ? 'right' : 'left' }) : undefined
|
|
269
|
+
});
|
|
270
|
+
if (!decoration) {
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
if (beforeCommandExecution) {
|
|
274
|
+
this._placeholderDecoration = decoration;
|
|
275
|
+
}
|
|
276
|
+
decoration.onRender(element => {
|
|
277
|
+
if (element.classList.contains(DecorationSelector.OverviewRuler)) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
if (!this._decorations.get(decoration.marker.id)) {
|
|
281
|
+
decoration.onDispose(() => this._decorations.delete(decoration.marker.id));
|
|
282
|
+
this._decorations.set(decoration.marker.id, {
|
|
283
|
+
decoration,
|
|
284
|
+
disposables: this._createDisposables(element, command, markProperties),
|
|
285
|
+
command,
|
|
286
|
+
markProperties: command?.markProperties || markProperties
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
if (!element.classList.contains(DecorationSelector.Codicon) || command?.marker?.line === 0) {
|
|
290
|
+
updateLayout(this._configurationService, element);
|
|
291
|
+
this._updateClasses(element, command, command?.markProperties || markProperties);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
return decoration;
|
|
295
|
+
}
|
|
296
|
+
registerMenuItems(command, items) {
|
|
297
|
+
const existingItems = this._registeredMenuItems.get(command);
|
|
298
|
+
if (existingItems) {
|
|
299
|
+
existingItems.push(...items);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
this._registeredMenuItems.set(command, [...items]);
|
|
303
|
+
}
|
|
304
|
+
return toDisposable(() => {
|
|
305
|
+
const commandItems = this._registeredMenuItems.get(command);
|
|
306
|
+
if (commandItems) {
|
|
307
|
+
for (const item of ( items.values())) {
|
|
308
|
+
const index = commandItems.indexOf(item);
|
|
309
|
+
if (index !== -1) {
|
|
310
|
+
commandItems.splice(index, 1);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
_createDisposables(element, command, markProperties) {
|
|
317
|
+
if (command?.exitCode === undefined && !command?.markProperties) {
|
|
318
|
+
return [];
|
|
319
|
+
}
|
|
320
|
+
else if (command?.markProperties || markProperties) {
|
|
321
|
+
return [this._createHover(element, command || markProperties, markProperties?.hoverMessage)];
|
|
322
|
+
}
|
|
323
|
+
return [...this._createContextMenu(element, command), this._createHover(element, command)];
|
|
324
|
+
}
|
|
325
|
+
_createHover(element, command, hoverMessage) {
|
|
326
|
+
return this._hoverService.setupDelayedHover(element, () => ({
|
|
327
|
+
content: ( new MarkdownString(getTerminalDecorationHoverContent(command, hoverMessage, true)))
|
|
328
|
+
}));
|
|
329
|
+
}
|
|
330
|
+
_updateClasses(element, command, markProperties) {
|
|
331
|
+
if (!element) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
for (const classes of element.classList) {
|
|
335
|
+
element.classList.remove(classes);
|
|
336
|
+
}
|
|
337
|
+
element.classList.add(DecorationSelector.CommandDecoration, DecorationSelector.Codicon, DecorationSelector.XtermDecoration);
|
|
338
|
+
if (markProperties) {
|
|
339
|
+
element.classList.add(DecorationSelector.DefaultColor, ...ThemeIcon.asClassNameArray(terminalDecorationMark));
|
|
340
|
+
if (!markProperties.hoverMessage) {
|
|
341
|
+
element.classList.add(DecorationSelector.Default);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
else {
|
|
345
|
+
const state = getTerminalCommandDecorationState(command);
|
|
346
|
+
this._updateCommandDecorationVisibility(element);
|
|
347
|
+
for (const className of state.classNames) {
|
|
348
|
+
element.classList.add(className);
|
|
349
|
+
}
|
|
350
|
+
element.classList.add(...ThemeIcon.asClassNameArray(state.icon));
|
|
351
|
+
}
|
|
352
|
+
element.removeAttribute('title');
|
|
353
|
+
element.removeAttribute('aria-label');
|
|
354
|
+
}
|
|
355
|
+
_createContextMenu(element, command) {
|
|
356
|
+
return [
|
|
357
|
+
addDisposableListener(element, EventType.MOUSE_DOWN, async (e) => {
|
|
358
|
+
e.stopImmediatePropagation();
|
|
359
|
+
}),
|
|
360
|
+
addDisposableListener(element, EventType.CLICK, async (e) => {
|
|
361
|
+
e.stopImmediatePropagation();
|
|
362
|
+
const actions = await this._getCommandActions(command);
|
|
363
|
+
this._contextMenuService.showContextMenu({ getAnchor: () => element, getActions: () => actions });
|
|
364
|
+
}),
|
|
365
|
+
addDisposableListener(element, EventType.CONTEXT_MENU, async (e) => {
|
|
366
|
+
e.stopImmediatePropagation();
|
|
367
|
+
const chatActions = await this._getCommandActions(command);
|
|
368
|
+
const actions = this._getContextMenuActions();
|
|
369
|
+
this._contextMenuService.showContextMenu({ getAnchor: () => element, getActions: () => [...actions, ...chatActions] });
|
|
370
|
+
}),
|
|
371
|
+
];
|
|
372
|
+
}
|
|
373
|
+
_getContextMenuActions() {
|
|
374
|
+
const label = ( localize(11647, "Toggle Visibility"));
|
|
375
|
+
return [
|
|
376
|
+
{
|
|
377
|
+
class: undefined, tooltip: label, id: 'terminal.toggleVisibility', label, enabled: true,
|
|
378
|
+
run: async () => {
|
|
379
|
+
this._showToggleVisibilityQuickPick();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
];
|
|
383
|
+
}
|
|
384
|
+
async _getCommandActions(command) {
|
|
385
|
+
const actions = [];
|
|
386
|
+
const registeredMenuItems = this._registeredMenuItems.get(command);
|
|
387
|
+
if (registeredMenuItems?.length) {
|
|
388
|
+
actions.push(...registeredMenuItems, ( new Separator()));
|
|
389
|
+
}
|
|
390
|
+
const attachToChatAction = this._createAttachToChatAction(command);
|
|
391
|
+
if (attachToChatAction) {
|
|
392
|
+
actions.push(attachToChatAction, ( new Separator()));
|
|
393
|
+
}
|
|
394
|
+
if (command.command !== '') {
|
|
395
|
+
const labelRun = ( localize(11648, 'Rerun Command'));
|
|
396
|
+
actions.push({
|
|
397
|
+
class: undefined, tooltip: labelRun, id: 'terminal.rerunCommand', label: labelRun, enabled: true,
|
|
398
|
+
run: async () => {
|
|
399
|
+
if (command.command === '') {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (!command.isTrusted) {
|
|
403
|
+
const shouldRun = await ( new Promise(r => {
|
|
404
|
+
this._notificationService.prompt(Severity.Info, ( localize(11649, 'Do you want to run the command: {0}', command.command)), [{
|
|
405
|
+
label: ( localize(11650, 'Yes')),
|
|
406
|
+
run: () => r(true)
|
|
407
|
+
}, {
|
|
408
|
+
label: ( localize(11651, 'No')),
|
|
409
|
+
run: () => r(false)
|
|
410
|
+
}]);
|
|
411
|
+
}));
|
|
412
|
+
if (!shouldRun) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
this._onDidRequestRunCommand.fire({ command });
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
actions.push(( new Separator()));
|
|
420
|
+
const labelCopy = ( localize(11652, 'Copy Command'));
|
|
421
|
+
actions.push({
|
|
422
|
+
class: undefined, tooltip: labelCopy, id: 'terminal.copyCommand', label: labelCopy, enabled: true,
|
|
423
|
+
run: () => this._clipboardService.writeText(command.command)
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
if (command.hasOutput()) {
|
|
427
|
+
const labelCopyCommandAndOutput = ( localize(11653, 'Copy Command and Output'));
|
|
428
|
+
actions.push({
|
|
429
|
+
class: undefined, tooltip: labelCopyCommandAndOutput, id: 'terminal.copyCommandAndOutput', label: labelCopyCommandAndOutput, enabled: true,
|
|
430
|
+
run: () => {
|
|
431
|
+
const output = command.getOutput();
|
|
432
|
+
if (isString(output)) {
|
|
433
|
+
this._clipboardService.writeText(`${command.command !== '' ? command.command + '\n' : ''}${output}`);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
const labelText = ( localize(11654, 'Copy Output'));
|
|
438
|
+
actions.push({
|
|
439
|
+
class: undefined, tooltip: labelText, id: 'terminal.copyOutput', label: labelText, enabled: true,
|
|
440
|
+
run: () => {
|
|
441
|
+
const text = command.getOutput();
|
|
442
|
+
if (isString(text)) {
|
|
443
|
+
this._clipboardService.writeText(text);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
});
|
|
447
|
+
const labelHtml = ( localize(11655, 'Copy Output as HTML'));
|
|
448
|
+
actions.push({
|
|
449
|
+
class: undefined, tooltip: labelHtml, id: 'terminal.copyOutputAsHtml', label: labelHtml, enabled: true,
|
|
450
|
+
run: () => this._onDidRequestCopyAsHtml.fire({ command })
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
if (actions.length > 0) {
|
|
454
|
+
actions.push(( new Separator()));
|
|
455
|
+
}
|
|
456
|
+
const labelRunRecent = ( localize(11656, "Run Recent Command"));
|
|
457
|
+
actions.push({
|
|
458
|
+
class: undefined, tooltip: labelRunRecent, id: 'workbench.action.terminal.runRecentCommand', label: labelRunRecent, enabled: true,
|
|
459
|
+
run: () => this._commandService.executeCommand('workbench.action.terminal.runRecentCommand')
|
|
460
|
+
});
|
|
461
|
+
const labelGoToRecent = ( localize(11657, "Go To Recent Directory"));
|
|
462
|
+
actions.push({
|
|
463
|
+
class: undefined, tooltip: labelRunRecent, id: 'workbench.action.terminal.goToRecentDirectory', label: labelGoToRecent, enabled: true,
|
|
464
|
+
run: () => this._commandService.executeCommand('workbench.action.terminal.goToRecentDirectory')
|
|
465
|
+
});
|
|
466
|
+
actions.push(( new Separator()));
|
|
467
|
+
const labelAbout = ( localize(11658, 'Learn About Shell Integration'));
|
|
468
|
+
actions.push({
|
|
469
|
+
class: undefined, tooltip: labelAbout, id: 'terminal.learnShellIntegration', label: labelAbout, enabled: true,
|
|
470
|
+
run: () => this._openerService.open('https://code.visualstudio.com/docs/terminal/shell-integration')
|
|
471
|
+
});
|
|
472
|
+
return actions;
|
|
473
|
+
}
|
|
474
|
+
_createAttachToChatAction(command) {
|
|
475
|
+
const chatIsEnabled = ( this._chatWidgetService.getWidgetsByLocations(ChatAgentLocation.Chat).some(w => w.attachmentCapabilities.supportsTerminalAttachments));
|
|
476
|
+
if (!chatIsEnabled) {
|
|
477
|
+
return undefined;
|
|
478
|
+
}
|
|
479
|
+
const labelAttachToChat = ( localize(11659, 'Attach To Chat'));
|
|
480
|
+
return {
|
|
481
|
+
class: undefined, tooltip: labelAttachToChat, id: 'terminal.attachToChat', label: labelAttachToChat, enabled: true,
|
|
482
|
+
run: async () => {
|
|
483
|
+
let widget = this._chatWidgetService.lastFocusedWidget ?? this._chatWidgetService.getWidgetsByLocations(ChatAgentLocation.Chat)?.find(w => w.attachmentCapabilities.supportsTerminalAttachments);
|
|
484
|
+
if (!widget) {
|
|
485
|
+
widget = await this._chatWidgetService.revealWidget();
|
|
486
|
+
}
|
|
487
|
+
if (!widget) {
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
let terminalContext;
|
|
491
|
+
if (this._resource) {
|
|
492
|
+
const parsedUri = parseTerminalUri(this._resource);
|
|
493
|
+
terminalContext = this._instantiationService.createInstance(TerminalContext, getTerminalUri(parsedUri.workspaceId, parsedUri.instanceId, undefined, command.id));
|
|
494
|
+
}
|
|
495
|
+
if (terminalContext && widget.attachmentCapabilities.supportsTerminalAttachments) {
|
|
496
|
+
try {
|
|
497
|
+
const attachment = await terminalContext.asAttachment(widget);
|
|
498
|
+
if (attachment) {
|
|
499
|
+
widget.attachmentModel.addContext(attachment);
|
|
500
|
+
widget.focusInput();
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
catch (err) {
|
|
505
|
+
}
|
|
506
|
+
this._store.add(this._contextPickService.registerChatContextItem(terminalContext));
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
_showToggleVisibilityQuickPick() {
|
|
512
|
+
const quickPick = this._register(this._quickInputService.createQuickPick());
|
|
513
|
+
quickPick.hideInput = true;
|
|
514
|
+
quickPick.hideCheckAll = true;
|
|
515
|
+
quickPick.canSelectMany = true;
|
|
516
|
+
quickPick.title = ( localize(11660, 'Toggle visibility'));
|
|
517
|
+
const configValue = this._configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationsEnabled);
|
|
518
|
+
const gutterIcon = {
|
|
519
|
+
label: ( localize(11661, 'Gutter command decorations')),
|
|
520
|
+
picked: configValue !== 'never' && configValue !== 'overviewRuler'
|
|
521
|
+
};
|
|
522
|
+
const overviewRulerIcon = {
|
|
523
|
+
label: ( localize(11662, 'Overview ruler command decorations')),
|
|
524
|
+
picked: configValue !== 'never' && configValue !== 'gutter'
|
|
525
|
+
};
|
|
526
|
+
quickPick.items = [gutterIcon, overviewRulerIcon];
|
|
527
|
+
const selectedItems = [];
|
|
528
|
+
if (configValue !== 'never') {
|
|
529
|
+
if (configValue !== 'gutter') {
|
|
530
|
+
selectedItems.push(gutterIcon);
|
|
531
|
+
}
|
|
532
|
+
if (configValue !== 'overviewRuler') {
|
|
533
|
+
selectedItems.push(overviewRulerIcon);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
quickPick.selectedItems = selectedItems;
|
|
537
|
+
this._register(quickPick.onDidChangeSelection(async (e) => {
|
|
538
|
+
let newValue = 'never';
|
|
539
|
+
if (e.includes(gutterIcon)) {
|
|
540
|
+
if (e.includes(overviewRulerIcon)) {
|
|
541
|
+
newValue = 'both';
|
|
542
|
+
}
|
|
543
|
+
else {
|
|
544
|
+
newValue = 'gutter';
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
else if (e.includes(overviewRulerIcon)) {
|
|
548
|
+
newValue = 'overviewRuler';
|
|
549
|
+
}
|
|
550
|
+
await this._configurationService.updateValue(TerminalSettingId.ShellIntegrationDecorationsEnabled, newValue);
|
|
551
|
+
}));
|
|
552
|
+
quickPick.ok = false;
|
|
553
|
+
quickPick.show();
|
|
554
|
+
}
|
|
555
|
+
_getDecorationCssColor(command) {
|
|
556
|
+
let colorId;
|
|
557
|
+
if (command?.exitCode === undefined) {
|
|
558
|
+
colorId = TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR;
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
colorId = command.exitCode ? TERMINAL_COMMAND_DECORATION_ERROR_BACKGROUND_COLOR : TERMINAL_COMMAND_DECORATION_SUCCESS_BACKGROUND_COLOR;
|
|
562
|
+
}
|
|
563
|
+
return this._themeService.getColorTheme().getColor(colorId)?.toString();
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
DecorationAddon = ( __decorate([
|
|
567
|
+
( __param(2, IClipboardService)),
|
|
568
|
+
( __param(3, IContextMenuService)),
|
|
569
|
+
( __param(4, IConfigurationService)),
|
|
570
|
+
( __param(5, IThemeService)),
|
|
571
|
+
( __param(6, IOpenerService)),
|
|
572
|
+
( __param(7, IQuickInputService)),
|
|
573
|
+
( __param(8, ILifecycleService)),
|
|
574
|
+
( __param(9, ICommandService)),
|
|
575
|
+
( __param(10, IAccessibilitySignalService)),
|
|
576
|
+
( __param(11, INotificationService)),
|
|
577
|
+
( __param(12, IHoverService)),
|
|
578
|
+
( __param(13, IChatContextPickService)),
|
|
579
|
+
( __param(14, IChatWidgetService)),
|
|
580
|
+
( __param(15, IInstantiationService))
|
|
581
|
+
], DecorationAddon));
|
|
582
|
+
|
|
583
|
+
export { DecorationAddon };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
2
|
+
import { IMarkTracker } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/terminal/browser/terminal";
|
|
3
|
+
import { ITerminalCapabilityStore, ITerminalCommand } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/capabilities";
|
|
4
|
+
import type { Terminal, IMarker, ITerminalAddon, IBufferRange } from "@xterm/xterm";
|
|
5
|
+
import { IThemeService } from "@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/themeService.service";
|
|
6
|
+
import { ICurrentPartialCommand } from "@codingame/monaco-vscode-api/vscode/vs/platform/terminal/common/capabilities/commandDetection/terminalCommand";
|
|
7
|
+
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
8
|
+
declare enum Boundary {
|
|
9
|
+
Top = 0,
|
|
10
|
+
Bottom = 1
|
|
11
|
+
}
|
|
12
|
+
export declare enum ScrollPosition {
|
|
13
|
+
Top = 0,
|
|
14
|
+
Middle = 1
|
|
15
|
+
}
|
|
16
|
+
export declare class MarkNavigationAddon extends Disposable implements IMarkTracker, ITerminalAddon {
|
|
17
|
+
private readonly _capabilities;
|
|
18
|
+
private readonly _configurationService;
|
|
19
|
+
private readonly _themeService;
|
|
20
|
+
private _currentMarker;
|
|
21
|
+
private _selectionStart;
|
|
22
|
+
private _isDisposable;
|
|
23
|
+
protected _terminal: Terminal | undefined;
|
|
24
|
+
private _navigationDecorations;
|
|
25
|
+
private _activeCommandGuide?;
|
|
26
|
+
private readonly _commandGuideDecorations;
|
|
27
|
+
activate(terminal: Terminal): void;
|
|
28
|
+
constructor(_capabilities: ITerminalCapabilityStore, _configurationService: IConfigurationService, _themeService: IThemeService);
|
|
29
|
+
private _getMarkers;
|
|
30
|
+
private _findCommand;
|
|
31
|
+
clear(): void;
|
|
32
|
+
private _resetNavigationDecorations;
|
|
33
|
+
private _isEmptyCommand;
|
|
34
|
+
scrollToPreviousMark(scrollPosition?: ScrollPosition, retainSelection?: boolean, skipEmptyCommands?: boolean): void;
|
|
35
|
+
scrollToNextMark(scrollPosition?: ScrollPosition, retainSelection?: boolean, skipEmptyCommands?: boolean): void;
|
|
36
|
+
private _scrollToCommand;
|
|
37
|
+
private _scrollToMarker;
|
|
38
|
+
private _createMarkerForOffset;
|
|
39
|
+
revealCommand(command: ITerminalCommand | ICurrentPartialCommand, position?: ScrollPosition): void;
|
|
40
|
+
revealRange(range: IBufferRange): void;
|
|
41
|
+
showCommandGuide(command: ITerminalCommand | undefined): void;
|
|
42
|
+
private _scrollState;
|
|
43
|
+
saveScrollState(): void;
|
|
44
|
+
restoreScrollState(): void;
|
|
45
|
+
private _highlightBufferRange;
|
|
46
|
+
registerTemporaryDecoration(marker: IMarker | number, endMarker: IMarker | number | undefined, showOutline: boolean): void;
|
|
47
|
+
scrollToLine(line: number, position: ScrollPosition): void;
|
|
48
|
+
getTargetScrollLine(line: number, position: ScrollPosition): number;
|
|
49
|
+
private _isMarkerInViewport;
|
|
50
|
+
scrollToClosestMarker(startMarkerId: string, endMarkerId?: string, highlight?: boolean | undefined): void;
|
|
51
|
+
selectToPreviousMark(): void;
|
|
52
|
+
selectToNextMark(): void;
|
|
53
|
+
selectToPreviousLine(): void;
|
|
54
|
+
selectToNextLine(): void;
|
|
55
|
+
scrollToPreviousLine(xterm: Terminal, scrollPosition?: ScrollPosition, retainSelection?: boolean): void;
|
|
56
|
+
scrollToNextLine(xterm: Terminal, scrollPosition?: ScrollPosition, retainSelection?: boolean): void;
|
|
57
|
+
private _registerMarkerOrThrow;
|
|
58
|
+
private _getOffset;
|
|
59
|
+
private _findPreviousMarker;
|
|
60
|
+
private _findNextMarker;
|
|
61
|
+
}
|
|
62
|
+
export declare function getLine(xterm: Terminal, marker: IMarker | Boundary): number;
|
|
63
|
+
export declare function selectLines(xterm: Terminal, start: IMarker | Boundary, end: IMarker | Boundary | null): void;
|
|
64
|
+
export {};
|