1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
|
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Disposable, IDisposable, dispose, toDisposable } from 'vs/base/common/lifecycle';
import { ITerminalCommand } from 'vs/workbench/contrib/terminal/common/terminal';
import { IDecoration, ITerminalAddon, Terminal } from 'xterm';
import * as dom from 'vs/base/browser/dom';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { CommandInvalidationReason, ITerminalCapabilityStore, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
import { IColorTheme, ICssStyleCollector, IThemeService, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
import { IAction, Separator } from 'vs/base/common/actions';
import { Emitter } from 'vs/base/common/event';
import { MarkdownString } from 'vs/base/common/htmlContent';
import { localize } from 'vs/nls';
import { Delayer } from 'vs/base/common/async';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { fromNow } from 'vs/base/common/date';
import { toolbarHoverBackground } from 'vs/platform/theme/common/colorRegistry';
import { TerminalSettingId } from 'vs/platform/terminal/common/terminal';
import { TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR, TERMINAL_COMMAND_DECORATION_ERROR_BACKGROUND_COLOR, TERMINAL_COMMAND_DECORATION_SUCCESS_BACKGROUND_COLOR } from 'vs/workbench/contrib/terminal/common/terminalColorRegistry';
import { Color } from 'vs/base/common/color';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IGenericMarkProperties } from 'vs/platform/terminal/common/terminalProcess';
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { Codicon } from 'vs/base/common/codicons';
const enum DecorationSelector {
CommandDecoration = 'terminal-command-decoration',
Hide = 'hide',
ErrorColor = 'error',
DefaultColor = 'default-color',
Default = 'default',
Codicon = 'codicon',
XtermDecoration = 'xterm-decoration',
GenericMarkerIcon = 'codicon-circle-small-filled',
OverviewRuler = '.xterm-decoration-overview-ruler'
}
const enum DecorationStyles {
DefaultDimension = 16,
MarginLeft = -17,
}
interface IDisposableDecoration { decoration: IDecoration; disposables: IDisposable[]; exitCode?: number; genericMarkProperties?: IGenericMarkProperties }
export class DecorationAddon extends Disposable implements ITerminalAddon {
protected _terminal: Terminal | undefined;
private _hoverDelayer: Delayer<void>;
private _commandDetectionListeners: IDisposable[] | undefined;
private _contextMenuVisible: boolean = false;
private _decorations: Map<number, IDisposableDecoration> = new Map();
private _placeholderDecoration: IDecoration | undefined;
private _showGutterDecorations?: boolean;
private _showOverviewRulerDecorations?: boolean;
private readonly _onDidRequestRunCommand = this._register(new Emitter<{ command: ITerminalCommand; copyAsHtml?: boolean }>());
readonly onDidRequestRunCommand = this._onDidRequestRunCommand.event;
constructor(
private readonly _capabilities: ITerminalCapabilityStore,
@IClipboardService private readonly _clipboardService: IClipboardService,
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
@IHoverService private readonly _hoverService: IHoverService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IThemeService private readonly _themeService: IThemeService,
@IOpenerService private readonly _openerService: IOpenerService,
@IQuickInputService private readonly _quickInputService: IQuickInputService
) {
super();
this._register(toDisposable(() => this._dispose()));
this._register(this._contextMenuService.onDidShowContextMenu(() => this._contextMenuVisible = true));
this._register(this._contextMenuService.onDidHideContextMenu(() => this._contextMenuVisible = false));
this._hoverDelayer = this._register(new Delayer(this._configurationService.getValue('workbench.hover.delay')));
this._configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationIcon) ||
e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationIconSuccess) ||
e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationIconError)) {
this._refreshStyles();
} else if (e.affectsConfiguration(TerminalSettingId.FontSize) || e.affectsConfiguration(TerminalSettingId.LineHeight)) {
this.refreshLayouts();
} else if (e.affectsConfiguration('workbench.colorCustomizations')) {
this._refreshStyles(true);
} else if (e.affectsConfiguration(TerminalSettingId.ShellIntegrationDecorationsEnabled)) {
if (this._commandDetectionListeners) {
dispose(this._commandDetectionListeners);
this._commandDetectionListeners = undefined;
}
this._updateDecorationVisibility();
}
});
this._themeService.onDidColorThemeChange(() => this._refreshStyles(true));
this._updateDecorationVisibility();
this._register(this._capabilities.onDidAddCapability(c => {
if (c === TerminalCapability.CommandDetection) {
this._addCommandDetectionListeners();
}
}));
this._register(this._capabilities.onDidRemoveCapability(c => {
if (c === TerminalCapability.CommandDetection) {
if (this._commandDetectionListeners) {
dispose(this._commandDetectionListeners);
this._commandDetectionListeners = undefined;
}
}
}));
}
private _updateDecorationVisibility(): void {
const showDecorations = this._configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationsEnabled);
this._showGutterDecorations = (showDecorations === 'both' || showDecorations === 'gutter');
this._showOverviewRulerDecorations = (showDecorations === 'both' || showDecorations === 'overviewRuler');
this._disposeAllDecorations();
if (this._showGutterDecorations || this._showOverviewRulerDecorations) {
this._attachToCommandCapability();
this._updateGutterDecorationVisibility();
}
const currentCommand = this._capabilities.get(TerminalCapability.CommandDetection)?.executingCommandObject;
if (currentCommand) {
this.registerCommandDecoration(currentCommand, true);
}
}
private _disposeAllDecorations(): void {
this._placeholderDecoration?.dispose();
for (const value of this._decorations.values()) {
value.decoration.dispose();
dispose(value.disposables);
}
}
private _updateGutterDecorationVisibility(): void {
const commandDecorationElements = document.querySelectorAll(DecorationSelector.CommandDecoration);
for (const commandDecorationElement of commandDecorationElements) {
this._updateCommandDecorationVisibility(commandDecorationElement);
}
}
private _updateCommandDecorationVisibility(commandDecorationElement: Element): void {
if (this._showGutterDecorations) {
commandDecorationElement.classList.remove(DecorationSelector.Hide);
} else {
commandDecorationElement.classList.add(DecorationSelector.Hide);
}
}
public refreshLayouts(): void {
this._updateLayout(this._placeholderDecoration?.element);
for (const decoration of this._decorations) {
this._updateLayout(decoration[1].decoration.element);
}
}
private _refreshStyles(refreshOverviewRulerColors?: boolean): void {
if (refreshOverviewRulerColors) {
for (const decoration of this._decorations.values()) {
let color = decoration.exitCode === undefined ? defaultColor : decoration.exitCode ? errorColor : successColor;
if (color && typeof color !== 'string') {
color = color.toString();
} else {
color = '';
}
if (decoration.decoration.options?.overviewRulerOptions) {
decoration.decoration.options.overviewRulerOptions.color = color;
} else if (decoration.decoration.options) {
decoration.decoration.options.overviewRulerOptions = { color };
}
}
}
this._updateClasses(this._placeholderDecoration?.element);
for (const decoration of this._decorations.values()) {
this._updateClasses(decoration.decoration.element, decoration.exitCode, decoration.genericMarkProperties);
}
}
private _dispose(): void {
if (this._commandDetectionListeners) {
dispose(this._commandDetectionListeners);
}
this.clearDecorations();
}
private _clearPlaceholder(): void {
this._placeholderDecoration?.dispose();
this._placeholderDecoration = undefined;
}
public clearDecorations(): void {
this._placeholderDecoration?.marker.dispose();
this._clearPlaceholder();
this._disposeAllDecorations();
this._decorations.clear();
}
private _attachToCommandCapability(): void {
if (this._capabilities.has(TerminalCapability.CommandDetection)) {
this._addCommandDetectionListeners();
}
}
private _addCommandDetectionListeners(): void {
if (this._commandDetectionListeners) {
return;
}
const capability = this._capabilities.get(TerminalCapability.CommandDetection);
if (!capability) {
return;
}
this._commandDetectionListeners = [];
// Command started
if (capability.executingCommandObject?.marker) {
this.registerCommandDecoration(capability.executingCommandObject, true);
}
this._commandDetectionListeners.push(capability.onCommandStarted(command => this.registerCommandDecoration(command, true)));
// Command finished
for (const command of capability.commands) {
this.registerCommandDecoration(command);
}
this._commandDetectionListeners.push(capability.onCommandFinished(command => this.registerCommandDecoration(command)));
// Command invalidated
this._commandDetectionListeners.push(capability.onCommandInvalidated(commands => {
for (const command of commands) {
const id = command.marker?.id;
if (id) {
const match = this._decorations.get(id);
if (match) {
match.decoration.dispose();
dispose(match.disposables);
}
}
}
}));
// Current command invalidated
this._commandDetectionListeners.push(capability.onCurrentCommandInvalidated((request) => {
if (request.reason === CommandInvalidationReason.NoProblemsReported) {
const lastDecoration = Array.from(this._decorations.entries())[this._decorations.size - 1];
lastDecoration?.[1].decoration.dispose();
} else if (request.reason === CommandInvalidationReason.Windows) {
this._clearPlaceholder();
}
}));
}
activate(terminal: Terminal): void {
this._terminal = terminal;
this._attachToCommandCapability();
}
registerCommandDecoration(command: ITerminalCommand, beforeCommandExecution?: boolean): IDecoration | undefined {
if (!this._terminal || (beforeCommandExecution && command.genericMarkProperties) || (!this._showGutterDecorations && !this._showOverviewRulerDecorations)) {
return undefined;
}
if (!command.marker) {
throw new Error(`cannot add a decoration for a command ${JSON.stringify(command)} with no marker`);
}
this._clearPlaceholder();
let color = command.exitCode === undefined ? defaultColor : command.exitCode ? errorColor : successColor;
if (color && typeof color !== 'string') {
color = color.toString();
} else {
color = '';
}
const decoration = this._terminal.registerDecoration({
marker: command.marker,
overviewRulerOptions: this._showOverviewRulerDecorations ? (beforeCommandExecution
? { color, position: 'left' }
: { color, position: command.exitCode ? 'right' : 'left' }) : undefined
});
if (!decoration) {
return undefined;
}
if (beforeCommandExecution) {
this._placeholderDecoration = decoration;
}
decoration.onRender(element => {
if (element.classList.contains(DecorationSelector.OverviewRuler)) {
return;
}
if (!this._decorations.get(decoration.marker.id)) {
decoration.onDispose(() => this._decorations.delete(decoration.marker.id));
this._decorations.set(decoration.marker.id,
{
decoration,
disposables: this._createDisposables(element, command),
exitCode: command.exitCode,
genericMarkProperties: command.genericMarkProperties
});
}
if (!element.classList.contains(DecorationSelector.Codicon) || command.marker?.line === 0) {
// first render or buffer was cleared
this._updateLayout(element);
this._updateClasses(element, command.exitCode, command.genericMarkProperties);
}
});
return decoration;
}
private _createDisposables(element: HTMLElement, command: ITerminalCommand): IDisposable[] {
if (command.exitCode === undefined && !command.genericMarkProperties) {
return [];
} else if (command.genericMarkProperties) {
return [...this._createHover(element, command)];
}
return [this._createContextMenu(element, command), ...this._createHover(element, command)];
}
private _updateLayout(element?: HTMLElement): void {
if (!element) {
return;
}
const fontSize = this._configurationService.inspect(TerminalSettingId.FontSize).value;
const defaultFontSize = this._configurationService.inspect(TerminalSettingId.FontSize).defaultValue;
const lineHeight = this._configurationService.inspect(TerminalSettingId.LineHeight).value;
if (typeof fontSize === 'number' && typeof defaultFontSize === 'number' && typeof lineHeight === 'number') {
const scalar = (fontSize / defaultFontSize) <= 1 ? (fontSize / defaultFontSize) : 1;
// must be inlined to override the inlined styles from xterm
element.style.width = `${scalar * DecorationStyles.DefaultDimension}px`;
element.style.height = `${scalar * DecorationStyles.DefaultDimension * lineHeight}px`;
element.style.fontSize = `${scalar * DecorationStyles.DefaultDimension}px`;
element.style.marginLeft = `${scalar * DecorationStyles.MarginLeft}px`;
}
}
private _updateClasses(element?: HTMLElement, exitCode?: number, genericMarkProperties?: IGenericMarkProperties): void {
if (!element) {
return;
}
for (const classes of element.classList) {
element.classList.remove(classes);
}
element.classList.add(DecorationSelector.CommandDecoration, DecorationSelector.Codicon, DecorationSelector.XtermDecoration);
if (genericMarkProperties) {
element.classList.add(DecorationSelector.DefaultColor, DecorationSelector.GenericMarkerIcon);
if (!genericMarkProperties.hoverMessage) {
//disable the mouse pointer
element.classList.add(DecorationSelector.Default);
}
} else {
// command decoration
this._updateCommandDecorationVisibility(element);
if (exitCode === undefined) {
element.classList.add(DecorationSelector.DefaultColor, DecorationSelector.Default);
element.classList.add(`codicon-${this._configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationIcon)}`);
} else if (exitCode) {
element.classList.add(DecorationSelector.ErrorColor);
element.classList.add(`codicon-${this._configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationIconError)}`);
} else {
element.classList.add(`codicon-${this._configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationIconSuccess)}`);
}
}
}
private _createContextMenu(element: HTMLElement, command: ITerminalCommand): IDisposable {
// When the xterm Decoration gets disposed of, its element gets removed from the dom
// along with its listeners
return dom.addDisposableListener(element, dom.EventType.CLICK, async () => {
this._hideHover();
const actions = await this._getCommandActions(command);
this._contextMenuService.showContextMenu({ getAnchor: () => element, getActions: () => actions });
});
}
private _createHover(element: HTMLElement, command: ITerminalCommand): IDisposable[] {
return [
dom.addDisposableListener(element, dom.EventType.MOUSE_ENTER, () => {
if (this._contextMenuVisible) {
return;
}
this._hoverDelayer.trigger(() => {
let hoverContent = `${localize('terminalPromptContextMenu', "Show Command Actions")}`;
hoverContent += '\n\n---\n\n';
if (command.genericMarkProperties) {
if (command.genericMarkProperties.hoverMessage) {
hoverContent = command.genericMarkProperties.hoverMessage;
} else {
return;
}
} else if (command.exitCode) {
if (command.exitCode === -1) {
hoverContent += localize('terminalPromptCommandFailed', 'Command executed {0} and failed', fromNow(command.timestamp, true));
} else {
hoverContent += localize('terminalPromptCommandFailedWithExitCode', 'Command executed {0} and failed (Exit Code {1})', fromNow(command.timestamp, true), command.exitCode);
}
} else {
hoverContent += localize('terminalPromptCommandSuccess', 'Command executed {0}', fromNow(command.timestamp, true));
}
this._hoverService.showHover({ content: new MarkdownString(hoverContent), target: element });
});
}),
dom.addDisposableListener(element, dom.EventType.MOUSE_LEAVE, () => this._hideHover()),
dom.addDisposableListener(element, dom.EventType.MOUSE_OUT, () => this._hideHover())
];
}
private _hideHover() {
this._hoverDelayer.cancel();
this._hoverService.hideHover();
}
private async _getCommandActions(command: ITerminalCommand): Promise<IAction[]> {
const actions: IAction[] = [];
if (command.command !== '') {
const labelRun = localize("terminal.rerunCommand", 'Rerun Command');
actions.push({
class: undefined, tooltip: labelRun, dispose: () => { }, id: 'terminal.rerunCommand', label: labelRun, enabled: true,
run: () => this._onDidRequestRunCommand.fire({ command })
});
const labelCopy = localize("terminal.copyCommand", 'Copy Command');
actions.push({
class: undefined, tooltip: labelCopy, dispose: () => { }, id: 'terminal.copyCommand', label: labelCopy, enabled: true,
run: () => this._clipboardService.writeText(command.command)
});
}
if (command.hasOutput()) {
if (actions.length > 0) {
actions.push(new Separator());
}
const labelText = localize("terminal.copyOutput", 'Copy Output');
actions.push({
class: undefined, tooltip: labelText, dispose: () => { }, id: 'terminal.copyOutput', label: labelText, enabled: true,
run: () => this._clipboardService.writeText(command.getOutput()!)
});
const labelHtml = localize("terminal.copyOutputAsHtml", 'Copy Output as HTML');
actions.push({
class: undefined, tooltip: labelHtml, dispose: () => { }, id: 'terminal.copyOutputAsHtml', label: labelHtml, enabled: true,
run: () => this._onDidRequestRunCommand.fire({ command, copyAsHtml: true })
});
}
if (actions.length > 0) {
actions.push(new Separator());
}
const labelConfigure = localize("terminal.configureCommandDecorations", 'Configure Command Decorations');
actions.push({
class: undefined, tooltip: labelConfigure, dispose: () => { }, id: 'terminal.configureCommandDecorations', label: labelConfigure, enabled: true,
run: () => this._showConfigureCommandDecorationsQuickPick()
});
const labelAbout = localize("terminal.learnShellIntegration", 'Learn About Shell Integration');
actions.push({
class: undefined, tooltip: labelAbout, dispose: () => { }, id: 'terminal.learnShellIntegration', label: labelAbout, enabled: true,
run: () => this._openerService.open('https://code.visualstudio.com/docs/editor/integrated-terminal#_shell-integration')
});
return actions;
}
private async _showConfigureCommandDecorationsQuickPick() {
const quickPick = this._quickInputService.createQuickPick();
quickPick.items = [
{ id: 'a', label: localize('changeDefaultIcon', 'Change default icon') },
{ id: 'b', label: localize('changeSuccessIcon', 'Change success icon') },
{ id: 'c', label: localize('changeErrorIcon', 'Change error icon') },
{ type: 'separator' },
{ id: 'd', label: localize('toggleVisibility', 'Toggle visibility') },
];
quickPick.canSelectMany = false;
quickPick.onDidAccept(async e => {
quickPick.hide();
const result = quickPick.activeItems[0];
let iconSetting: string | undefined;
switch (result.id) {
case 'a': iconSetting = TerminalSettingId.ShellIntegrationDecorationIcon; break;
case 'b': iconSetting = TerminalSettingId.ShellIntegrationDecorationIconSuccess; break;
case 'c': iconSetting = TerminalSettingId.ShellIntegrationDecorationIconError; break;
case 'd': this._showToggleVisibilityQuickPick(); break;
}
if (iconSetting) {
this._showChangeIconQuickPick(iconSetting);
}
});
quickPick.show();
}
private async _showChangeIconQuickPick(iconSetting: string) {
type Item = IQuickPickItem & { icon: Codicon };
const items: Item[] = [];
for (const icon of Codicon.getAll()) {
items.push({ label: `$(${icon.id})`, description: `${icon.id}`, icon });
}
const result = await this._quickInputService.pick(items, {
matchOnDescription: true
});
if (result) {
this._configurationService.updateValue(iconSetting, result.icon.id);
this._showConfigureCommandDecorationsQuickPick();
}
}
private _showToggleVisibilityQuickPick() {
const quickPick = this._quickInputService.createQuickPick();
quickPick.hideInput = true;
quickPick.hideCheckAll = true;
quickPick.canSelectMany = true;
quickPick.title = localize('toggleVisibility', 'Toggle visibility');
const configValue = this._configurationService.getValue(TerminalSettingId.ShellIntegrationDecorationsEnabled);
const gutterIcon: IQuickPickItem = {
label: localize('gutter', 'Gutter command decorations'),
picked: configValue !== 'never' && configValue !== 'overviewRuler'
};
const overviewRulerIcon: IQuickPickItem = {
label: localize('overviewRuler', 'Overview ruler command decorations'),
picked: configValue !== 'never' && configValue !== 'gutter'
};
quickPick.items = [gutterIcon, overviewRulerIcon];
const selectedItems: IQuickPickItem[] = [];
if (configValue !== 'never') {
if (configValue !== 'gutter') {
selectedItems.push(gutterIcon);
}
if (configValue !== 'overviewRuler') {
selectedItems.push(overviewRulerIcon);
}
}
quickPick.selectedItems = selectedItems;
quickPick.onDidChangeSelection(async e => {
let newValue: 'both' | 'gutter' | 'overviewRuler' | 'never' = 'never';
if (e.includes(gutterIcon)) {
if (e.includes(overviewRulerIcon)) {
newValue = 'both';
} else {
newValue = 'gutter';
}
} else if (e.includes(overviewRulerIcon)) {
newValue = 'overviewRuler';
}
await this._configurationService.updateValue(TerminalSettingId.ShellIntegrationDecorationsEnabled, newValue);
});
quickPick.show();
}
}
let successColor: string | Color | undefined;
let errorColor: string | Color | undefined;
let defaultColor: string | Color | undefined;
registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {
successColor = theme.getColor(TERMINAL_COMMAND_DECORATION_SUCCESS_BACKGROUND_COLOR);
errorColor = theme.getColor(TERMINAL_COMMAND_DECORATION_ERROR_BACKGROUND_COLOR);
defaultColor = theme.getColor(TERMINAL_COMMAND_DECORATION_DEFAULT_BACKGROUND_COLOR);
const hoverBackgroundColor = theme.getColor(toolbarHoverBackground);
if (successColor) {
collector.addRule(`.${DecorationSelector.CommandDecoration} { color: ${successColor.toString()}; } `);
}
if (errorColor) {
collector.addRule(`.${DecorationSelector.CommandDecoration}.${DecorationSelector.ErrorColor} { color: ${errorColor.toString()}; } `);
}
if (defaultColor) {
collector.addRule(`.${DecorationSelector.CommandDecoration}.${DecorationSelector.DefaultColor} { color: ${defaultColor.toString()};} `);
}
if (hoverBackgroundColor) {
collector.addRule(`.${DecorationSelector.CommandDecoration}:not(.${DecorationSelector.DefaultColor}):hover { background-color: ${hoverBackgroundColor.toString()}; }`);
}
});
|