@codingame/monaco-vscode-api 1.83.15-next.0 → 1.83.16

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.
Files changed (53) hide show
  1. package/README.md +430 -0
  2. package/contributions.js +3 -0
  3. package/localExtensionHost.js +3 -2
  4. package/missing-services.js +57 -1
  5. package/monaco-editor-treemending.patch +3375 -3375
  6. package/package.json +6 -6
  7. package/vscode/src/vs/base/common/prefixTree.js +130 -0
  8. package/vscode/src/vs/platform/actions/browser/floatingMenu.js +26 -2
  9. package/vscode/src/vs/platform/terminal/common/capabilities/bufferMarkCapability.js +41 -0
  10. package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +566 -0
  11. package/vscode/src/vs/platform/terminal/common/capabilities/cwdDetectionCapability.js +29 -0
  12. package/vscode/src/vs/platform/terminal/common/capabilities/partialCommandDetectionCapability.js +48 -0
  13. package/vscode/src/vs/platform/terminal/common/capabilities/terminalCapabilityStore.js +94 -0
  14. package/vscode/src/vs/platform/terminal/common/terminalEnvironment.js +37 -0
  15. package/vscode/src/vs/platform/terminal/common/terminalStrings.js +16 -0
  16. package/vscode/src/vs/platform/terminal/common/xterm/shellIntegrationAddon.js +319 -0
  17. package/vscode/src/vs/workbench/contrib/codeEditor/browser/suggestEnabledInput/suggestEnabledInput.js +91 -1
  18. package/vscode/src/vs/workbench/contrib/format/browser/formatActionsMultiple.js +423 -0
  19. package/vscode/src/vs/workbench/contrib/format/browser/formatActionsNone.js +82 -0
  20. package/vscode/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.js +564 -11
  21. package/vscode/src/vs/workbench/contrib/scm/common/scm.js +9 -1
  22. package/vscode/src/vs/workbench/contrib/terminal/browser/detachedTerminal.js +67 -0
  23. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalExtensions.js +25 -0
  24. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalIcons.js +64 -0
  25. package/vscode/src/vs/workbench/contrib/terminal/browser/widgets/widgetManager.js +36 -0
  26. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +538 -0
  27. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationStyles.js +104 -0
  28. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +416 -0
  29. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/suggestAddon.js +390 -0
  30. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +799 -0
  31. package/vscode/src/vs/workbench/contrib/testing/common/getComputedState.js +101 -0
  32. package/vscode/src/vs/workbench/contrib/testing/common/observableValue.js +30 -0
  33. package/vscode/src/vs/workbench/contrib/testing/common/storedValue.js +36 -0
  34. package/vscode/src/vs/workbench/contrib/testing/common/testExplorerFilterState.js +116 -0
  35. package/vscode/src/vs/workbench/contrib/testing/common/testProfileService.js +172 -1
  36. package/vscode/src/vs/workbench/contrib/testing/common/testResult.js +384 -0
  37. package/vscode/src/vs/workbench/contrib/testing/common/testResultService.js +156 -1
  38. package/vscode/src/vs/workbench/contrib/testing/common/testResultStorage.js +156 -0
  39. package/vscode/src/vs/workbench/contrib/testing/common/testService.js +75 -1
  40. package/vscode/src/vs/workbench/contrib/testing/common/testTypes.js +9 -1
  41. package/vscode/src/vs/workbench/contrib/testing/common/testingContextKeys.js +179 -0
  42. package/vscode/src/vs/workbench/contrib/testing/common/testingContinuousRunService.js +102 -0
  43. package/vscode/src/vs/workbench/contrib/testing/common/testingDecorations.js +29 -0
  44. package/vscode/src/vs/workbench/contrib/testing/common/testingPeekOpener.js +3 -0
  45. package/vscode/src/vs/workbench/contrib/testing/common/testingStates.js +47 -0
  46. package/vscode/src/vs/workbench/services/authentication/browser/authenticationService.js +594 -2
  47. package/vscode/src/vs/workbench/services/extensions/browser/extensionUrlHandler.js +307 -1
  48. package/vscode/src/vs/workbench/services/suggest/browser/media/suggest.css.js +4 -0
  49. package/vscode/src/vs/workbench/services/suggest/browser/simpleCompletionItem.js +10 -0
  50. package/vscode/src/vs/workbench/services/suggest/browser/simpleCompletionModel.js +98 -0
  51. package/vscode/src/vs/workbench/services/suggest/browser/simpleSuggestWidget.js +428 -0
  52. package/vscode/src/vs/workbench/services/suggest/browser/simpleSuggestWidgetRenderer.js +83 -0
  53. package/vscode/src/vs/workbench/services/textfile/common/textfiles.js +6 -2
@@ -0,0 +1,799 @@
1
+ import { __decorate, __param } from '../../../../../../../../external/tslib/tslib.es6.js';
2
+ import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
3
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
4
+ import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
5
+ import { ITerminalLogService } from '../../../../../platform/terminal/common/terminal.js';
6
+ import { isSafari } from 'monaco-editor/esm/vs/base/browser/browser.js';
7
+ import { LogLevel } from 'monaco-editor/esm/vs/platform/log/common/log.js';
8
+ import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
9
+ import { Severity, INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
10
+ import { MarkNavigationAddon } from './markNavigationAddon.js';
11
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
12
+ import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
13
+ import { PANEL_BACKGROUND } from '../../../../common/theme.js';
14
+ import { TERMINAL_BACKGROUND_COLOR, TERMINAL_FIND_MATCH_BACKGROUND_COLOR, TERMINAL_FIND_MATCH_BORDER_COLOR, TERMINAL_OVERVIEW_RULER_CURSOR_FOREGROUND_COLOR, TERMINAL_FIND_MATCH_HIGHLIGHT_BACKGROUND_COLOR, TERMINAL_FIND_MATCH_HIGHLIGHT_BORDER_COLOR, TERMINAL_OVERVIEW_RULER_FIND_MATCH_FOREGROUND_COLOR, TERMINAL_FOREGROUND_COLOR, TERMINAL_CURSOR_FOREGROUND_COLOR, TERMINAL_CURSOR_BACKGROUND_COLOR, TERMINAL_SELECTION_BACKGROUND_COLOR, TERMINAL_INACTIVE_SELECTION_BACKGROUND_COLOR, TERMINAL_SELECTION_FOREGROUND_COLOR, ansiColorIdentifiers } from '../../common/terminalColorRegistry.js';
15
+ import { ShellIntegrationAddon } from '../../../../../platform/terminal/common/xterm/shellIntegrationAddon.js';
16
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
17
+ import { DecorationAddon } from './decorationAddon.js';
18
+ import { Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
19
+ import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
20
+ import { SuggestAddon } from './suggestAddon.js';
21
+ import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
22
+ import { TerminalContextKeys } from '../../common/terminalContextKey.js';
23
+ import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
24
+ import { debounce } from 'monaco-editor/esm/vs/base/common/decorators.js';
25
+ import { MouseWheelClassifier } from 'monaco-editor/esm/vs/base/browser/ui/scrollbar/scrollableElement.js';
26
+ import { StandardWheelEvent } from 'monaco-editor/esm/vs/base/browser/mouseEvent.js';
27
+ var XtermTerminal_1;
28
+ let CanvasAddon;
29
+ let ImageAddon;
30
+ let SearchAddon;
31
+ let SerializeAddon;
32
+ let Unicode11Addon;
33
+ let WebglAddon;
34
+ function getFullBufferLineAsString(lineIndex, buffer) {
35
+ let line = buffer.getLine(lineIndex);
36
+ if (!line) {
37
+ return { lineData: undefined, lineIndex };
38
+ }
39
+ let lineData = line.translateToString(true);
40
+ while (lineIndex > 0 && line.isWrapped) {
41
+ line = buffer.getLine(--lineIndex);
42
+ if (!line) {
43
+ break;
44
+ }
45
+ lineData = line.translateToString(false) + lineData;
46
+ }
47
+ return { lineData, lineIndex };
48
+ }
49
+ let XtermTerminal = class XtermTerminal extends Disposable {
50
+ static { XtermTerminal_1 = this; }
51
+ static { this._suggestedRendererType = undefined; }
52
+ static { this._checkedWebglCompatible = false; }
53
+ get findResult() { return this._lastFindResult; }
54
+ get isStdinDisabled() { return !!this.raw.options.disableStdin; }
55
+ get markTracker() { return this._markNavigationAddon; }
56
+ get shellIntegration() { return this._shellIntegrationAddon; }
57
+ get suggestController() { return this._suggestAddon; }
58
+ get textureAtlas() {
59
+ const canvas = this._webglAddon?.textureAtlas || this._canvasAddon?.textureAtlas;
60
+ if (!canvas) {
61
+ return undefined;
62
+ }
63
+ return createImageBitmap(canvas);
64
+ }
65
+ get isFocused() {
66
+ return !!this.raw.element?.contains(document.activeElement);
67
+ }
68
+ constructor(xtermCtor, _configHelper, cols, rows, _backgroundColorProvider, _capabilities, shellIntegrationNonce, _terminalSuggestWidgetVisibleContextKey, disableShellIntegrationReporting, _configurationService, _instantiationService, _logService, _notificationService, _storageService, _themeService, _telemetryService, _clipboardService, contextKeyService) {
69
+ super();
70
+ this._configHelper = _configHelper;
71
+ this._backgroundColorProvider = _backgroundColorProvider;
72
+ this._capabilities = _capabilities;
73
+ this._terminalSuggestWidgetVisibleContextKey = _terminalSuggestWidgetVisibleContextKey;
74
+ this._configurationService = _configurationService;
75
+ this._instantiationService = _instantiationService;
76
+ this._logService = _logService;
77
+ this._notificationService = _notificationService;
78
+ this._storageService = _storageService;
79
+ this._themeService = _themeService;
80
+ this._telemetryService = _telemetryService;
81
+ this._clipboardService = _clipboardService;
82
+ this._isPhysicalMouseWheel = MouseWheelClassifier.INSTANCE.isPhysicalMouseWheel();
83
+ this._attachedDisposables = this._register(( new DisposableStore()));
84
+ this._onDidRequestRunCommand = this._register(( new Emitter()));
85
+ this.onDidRequestRunCommand = this._onDidRequestRunCommand.event;
86
+ this._onDidRequestFocus = this._register(( new Emitter()));
87
+ this.onDidRequestFocus = this._onDidRequestFocus.event;
88
+ this._onDidRequestSendText = this._register(( new Emitter()));
89
+ this.onDidRequestSendText = this._onDidRequestSendText.event;
90
+ this._onDidRequestFreePort = this._register(( new Emitter()));
91
+ this.onDidRequestFreePort = this._onDidRequestFreePort.event;
92
+ this._onDidChangeFindResults = this._register(( new Emitter()));
93
+ this.onDidChangeFindResults = this._onDidChangeFindResults.event;
94
+ this._onDidChangeSelection = this._register(( new Emitter()));
95
+ this.onDidChangeSelection = this._onDidChangeSelection.event;
96
+ this._onDidChangeFocus = this._register(( new Emitter()));
97
+ this.onDidChangeFocus = this._onDidChangeFocus.event;
98
+ this._onDidDispose = this._register(( new Emitter()));
99
+ this.onDidDispose = this._onDidDispose.event;
100
+ const font = this._configHelper.getFont(undefined, true);
101
+ const config = this._configHelper.config;
102
+ const editorOptions = this._configurationService.getValue('editor');
103
+ this.raw = this._register(( new xtermCtor({
104
+ allowProposedApi: true,
105
+ cols,
106
+ rows,
107
+ altClickMovesCursor: config.altClickMovesCursor && editorOptions.multiCursorModifier === 'alt',
108
+ scrollback: config.scrollback,
109
+ theme: this._getXtermTheme(),
110
+ drawBoldTextInBrightColors: config.drawBoldTextInBrightColors,
111
+ fontFamily: font.fontFamily,
112
+ fontWeight: config.fontWeight,
113
+ fontWeightBold: config.fontWeightBold,
114
+ fontSize: font.fontSize,
115
+ letterSpacing: font.letterSpacing,
116
+ lineHeight: font.lineHeight,
117
+ logLevel: vscodeToXtermLogLevel(this._logService.getLevel()),
118
+ logger: this._logService,
119
+ minimumContrastRatio: config.minimumContrastRatio,
120
+ tabStopWidth: config.tabStopWidth,
121
+ cursorBlink: config.cursorBlinking,
122
+ cursorStyle: vscodeToXtermCursorStyle(config.cursorStyle),
123
+ cursorInactiveStyle: vscodeToXtermCursorStyle(config.cursorStyleInactive),
124
+ cursorWidth: config.cursorWidth,
125
+ macOptionIsMeta: config.macOptionIsMeta,
126
+ macOptionClickForcesSelection: config.macOptionClickForcesSelection,
127
+ rightClickSelectsWord: config.rightClickBehavior === 'selectWord',
128
+ fastScrollModifier: 'alt',
129
+ fastScrollSensitivity: config.fastScrollSensitivity,
130
+ scrollSensitivity: config.mouseWheelScrollSensitivity,
131
+ wordSeparator: config.wordSeparators,
132
+ overviewRulerWidth: 10,
133
+ ignoreBracketedPasteMode: config.ignoreBracketedPasteMode
134
+ })));
135
+ this._updateSmoothScrolling();
136
+ this._core = this.raw._core;
137
+ this._register(this._configurationService.onDidChangeConfiguration(async (e) => {
138
+ if (e.affectsConfiguration("terminal.integrated.gpuAcceleration" )) {
139
+ XtermTerminal_1._suggestedRendererType = undefined;
140
+ }
141
+ if (e.affectsConfiguration('terminal.integrated') || e.affectsConfiguration('editor.fastScrollSensitivity') || e.affectsConfiguration('editor.mouseWheelScrollSensitivity') || e.affectsConfiguration('editor.multiCursorModifier')) {
142
+ this.updateConfig();
143
+ }
144
+ if (e.affectsConfiguration("terminal.integrated.unicodeVersion" )) {
145
+ this._updateUnicodeVersion();
146
+ }
147
+ }));
148
+ this._register(this._themeService.onDidColorThemeChange(theme => this._updateTheme(theme)));
149
+ this._register(this._logService.onDidChangeLogLevel(e => this.raw.options.logLevel = vscodeToXtermLogLevel(e)));
150
+ this._register(this.raw.onSelectionChange(() => {
151
+ this._onDidChangeSelection.fire();
152
+ if (this.isFocused) {
153
+ this._anyFocusedTerminalHasSelection.set(this.raw.hasSelection());
154
+ }
155
+ }));
156
+ this._updateUnicodeVersion();
157
+ this._markNavigationAddon = this._instantiationService.createInstance(MarkNavigationAddon, _capabilities);
158
+ this.raw.loadAddon(this._markNavigationAddon);
159
+ this._decorationAddon = this._instantiationService.createInstance(DecorationAddon, this._capabilities);
160
+ this._register(this._decorationAddon.onDidRequestRunCommand(e => this._onDidRequestRunCommand.fire(e)));
161
+ this.raw.loadAddon(this._decorationAddon);
162
+ this._shellIntegrationAddon = ( new ShellIntegrationAddon(
163
+ shellIntegrationNonce,
164
+ disableShellIntegrationReporting,
165
+ this._telemetryService,
166
+ this._logService
167
+ ));
168
+ this.raw.loadAddon(this._shellIntegrationAddon);
169
+ this._anyTerminalFocusContextKey = TerminalContextKeys.focusInAny.bindTo(contextKeyService);
170
+ this._anyFocusedTerminalHasSelection = TerminalContextKeys.textSelectedInFocused.bindTo(contextKeyService);
171
+ if (this._terminalSuggestWidgetVisibleContextKey) {
172
+ this._suggestAddon = this._register(this._instantiationService.createInstance(SuggestAddon, this._terminalSuggestWidgetVisibleContextKey));
173
+ this.raw.loadAddon(this._suggestAddon);
174
+ this._register(this._suggestAddon.onAcceptedCompletion(async (text) => {
175
+ this._onDidRequestFocus.fire();
176
+ this._onDidRequestSendText.fire(text);
177
+ }));
178
+ }
179
+ }
180
+ *getBufferReverseIterator() {
181
+ for (let i = this.raw.buffer.active.length; i >= 0; i--) {
182
+ const { lineData, lineIndex } = getFullBufferLineAsString(i, this.raw.buffer.active);
183
+ if (lineData) {
184
+ i = lineIndex;
185
+ yield lineData;
186
+ }
187
+ }
188
+ }
189
+ async getContentsAsHtml() {
190
+ if (!this._serializeAddon) {
191
+ const Addon = await this._getSerializeAddonConstructor();
192
+ this._serializeAddon = ( new Addon());
193
+ this.raw.loadAddon(this._serializeAddon);
194
+ }
195
+ return this._serializeAddon.serializeAsHTML();
196
+ }
197
+ async getSelectionAsHtml(command) {
198
+ if (!this._serializeAddon) {
199
+ const Addon = await this._getSerializeAddonConstructor();
200
+ this._serializeAddon = ( new Addon());
201
+ this.raw.loadAddon(this._serializeAddon);
202
+ }
203
+ if (command) {
204
+ const length = command.getOutput()?.length;
205
+ const row = command.marker?.line;
206
+ if (!length || !row) {
207
+ throw new Error(`No row ${row} or output length ${length} for command ${command}`);
208
+ }
209
+ this.raw.select(0, row + 1, length - Math.floor(length / this.raw.cols));
210
+ }
211
+ const result = this._serializeAddon.serializeAsHTML({ onlySelection: true });
212
+ if (command) {
213
+ this.raw.clearSelection();
214
+ }
215
+ return result;
216
+ }
217
+ attachToElement(container, partialOptions) {
218
+ const options = { enableGpu: true, ...partialOptions };
219
+ if (!this._attached) {
220
+ this.raw.open(container);
221
+ }
222
+ if (options.enableGpu) {
223
+ if (this._shouldLoadWebgl()) {
224
+ this._enableWebglRenderer();
225
+ }
226
+ else if (this._shouldLoadCanvas()) {
227
+ this._enableCanvasRenderer();
228
+ }
229
+ }
230
+ if (!this.raw.element || !this.raw.textarea) {
231
+ throw new Error('xterm elements not set after open');
232
+ }
233
+ const ad = this._attachedDisposables;
234
+ ad.clear();
235
+ ad.add(dom.addDisposableListener(this.raw.textarea, 'focus', () => this._setFocused(true)));
236
+ ad.add(dom.addDisposableListener(this.raw.textarea, 'blur', () => this._setFocused(false)));
237
+ ad.add(dom.addDisposableListener(this.raw.textarea, 'focusout', () => this._setFocused(false)));
238
+ ad.add(dom.addDisposableListener(this.raw.element, dom.EventType.MOUSE_WHEEL, (e) => {
239
+ const classifier = MouseWheelClassifier.INSTANCE;
240
+ classifier.acceptStandardWheelEvent(( new StandardWheelEvent(e)));
241
+ const value = classifier.isPhysicalMouseWheel();
242
+ if (value !== this._isPhysicalMouseWheel) {
243
+ this._isPhysicalMouseWheel = value;
244
+ this._updateSmoothScrolling();
245
+ }
246
+ }, { passive: true }));
247
+ this._suggestAddon?.setContainer(container);
248
+ this._attached = { container, options };
249
+ return this._attached?.container.querySelector('.xterm-screen');
250
+ }
251
+ _setFocused(isFocused) {
252
+ this._onDidChangeFocus.fire(isFocused);
253
+ this._anyTerminalFocusContextKey.set(isFocused);
254
+ this._anyFocusedTerminalHasSelection.set(isFocused && this.raw.hasSelection());
255
+ }
256
+ write(data, callback) {
257
+ this.raw.write(data, callback);
258
+ }
259
+ resize(columns, rows) {
260
+ this.raw.resize(columns, rows);
261
+ }
262
+ updateConfig() {
263
+ const config = this._configHelper.config;
264
+ this.raw.options.altClickMovesCursor = config.altClickMovesCursor;
265
+ this._setCursorBlink(config.cursorBlinking);
266
+ this._setCursorStyle(config.cursorStyle);
267
+ this._setCursorStyleInactive(config.cursorStyleInactive);
268
+ this._setCursorWidth(config.cursorWidth);
269
+ this.raw.options.scrollback = config.scrollback;
270
+ this.raw.options.drawBoldTextInBrightColors = config.drawBoldTextInBrightColors;
271
+ this.raw.options.minimumContrastRatio = config.minimumContrastRatio;
272
+ this.raw.options.tabStopWidth = config.tabStopWidth;
273
+ this.raw.options.fastScrollSensitivity = config.fastScrollSensitivity;
274
+ this.raw.options.scrollSensitivity = config.mouseWheelScrollSensitivity;
275
+ this.raw.options.macOptionIsMeta = config.macOptionIsMeta;
276
+ const editorOptions = this._configurationService.getValue('editor');
277
+ this.raw.options.altClickMovesCursor = config.altClickMovesCursor && editorOptions.multiCursorModifier === 'alt';
278
+ this.raw.options.macOptionClickForcesSelection = config.macOptionClickForcesSelection;
279
+ this.raw.options.rightClickSelectsWord = config.rightClickBehavior === 'selectWord';
280
+ this.raw.options.wordSeparator = config.wordSeparators;
281
+ this.raw.options.customGlyphs = config.customGlyphs;
282
+ this.raw.options.ignoreBracketedPasteMode = config.ignoreBracketedPasteMode;
283
+ this._updateSmoothScrolling();
284
+ if (this._attached?.options.enableGpu) {
285
+ if (this._shouldLoadWebgl()) {
286
+ this._enableWebglRenderer();
287
+ }
288
+ else {
289
+ this._disposeOfWebglRenderer();
290
+ if (this._shouldLoadCanvas()) {
291
+ this._enableCanvasRenderer();
292
+ }
293
+ else {
294
+ this._disposeOfCanvasRenderer();
295
+ }
296
+ }
297
+ }
298
+ }
299
+ _updateSmoothScrolling() {
300
+ this.raw.options.smoothScrollDuration = this._configHelper.config.smoothScrolling && this._isPhysicalMouseWheel ? 125 : 0;
301
+ }
302
+ _shouldLoadWebgl() {
303
+ return !isSafari && (this._configHelper.config.gpuAcceleration === 'auto' && XtermTerminal_1._suggestedRendererType === undefined) || this._configHelper.config.gpuAcceleration === 'on';
304
+ }
305
+ _shouldLoadCanvas() {
306
+ return (this._configHelper.config.gpuAcceleration === 'auto' && (XtermTerminal_1._suggestedRendererType === undefined || XtermTerminal_1._suggestedRendererType === 'canvas')) || this._configHelper.config.gpuAcceleration === 'canvas';
307
+ }
308
+ forceRedraw() {
309
+ this.raw.clearTextureAtlas();
310
+ }
311
+ clearDecorations() {
312
+ this._decorationAddon?.clearDecorations();
313
+ }
314
+ forceRefresh() {
315
+ this._core.viewport?._innerRefresh();
316
+ }
317
+ forceUnpause() {
318
+ if (!!this._canvasAddon) {
319
+ this._core._renderService?._handleIntersectionChange({ intersectionRatio: 1 });
320
+ this.raw.refresh(0, this.raw.rows - 1);
321
+ }
322
+ }
323
+ async findNext(term, searchOptions) {
324
+ this._updateFindColors(searchOptions);
325
+ return (await this._getSearchAddon()).findNext(term, searchOptions);
326
+ }
327
+ async findPrevious(term, searchOptions) {
328
+ this._updateFindColors(searchOptions);
329
+ return (await this._getSearchAddon()).findPrevious(term, searchOptions);
330
+ }
331
+ _updateFindColors(searchOptions) {
332
+ const theme = this._themeService.getColorTheme();
333
+ const terminalBackground = theme.getColor(TERMINAL_BACKGROUND_COLOR) || theme.getColor(PANEL_BACKGROUND);
334
+ const findMatchBackground = theme.getColor(TERMINAL_FIND_MATCH_BACKGROUND_COLOR);
335
+ const findMatchBorder = theme.getColor(TERMINAL_FIND_MATCH_BORDER_COLOR);
336
+ const findMatchOverviewRuler = theme.getColor(TERMINAL_OVERVIEW_RULER_CURSOR_FOREGROUND_COLOR);
337
+ const findMatchHighlightBackground = theme.getColor(TERMINAL_FIND_MATCH_HIGHLIGHT_BACKGROUND_COLOR);
338
+ const findMatchHighlightBorder = theme.getColor(TERMINAL_FIND_MATCH_HIGHLIGHT_BORDER_COLOR);
339
+ const findMatchHighlightOverviewRuler = theme.getColor(TERMINAL_OVERVIEW_RULER_FIND_MATCH_FOREGROUND_COLOR);
340
+ searchOptions.decorations = {
341
+ activeMatchBackground: findMatchBackground?.toString(),
342
+ activeMatchBorder: findMatchBorder?.toString() || 'transparent',
343
+ activeMatchColorOverviewRuler: findMatchOverviewRuler?.toString() || 'transparent',
344
+ matchBackground: terminalBackground ? findMatchHighlightBackground?.blend(terminalBackground).toString() : undefined,
345
+ matchBorder: findMatchHighlightBorder?.toString() || 'transparent',
346
+ matchOverviewRuler: findMatchHighlightOverviewRuler?.toString() || 'transparent'
347
+ };
348
+ }
349
+ _getSearchAddon() {
350
+ if (!this._searchAddonPromise) {
351
+ this._searchAddonPromise = this._getSearchAddonConstructor().then((AddonCtor) => {
352
+ this._searchAddon = ( new AddonCtor({ highlightLimit: 1000 }));
353
+ this.raw.loadAddon(this._searchAddon);
354
+ this._searchAddon.onDidChangeResults((results) => {
355
+ this._lastFindResult = results;
356
+ this._onDidChangeFindResults.fire(results);
357
+ });
358
+ return this._searchAddon;
359
+ });
360
+ }
361
+ return this._searchAddonPromise;
362
+ }
363
+ clearSearchDecorations() {
364
+ this._searchAddon?.clearDecorations();
365
+ }
366
+ clearActiveSearchDecoration() {
367
+ this._searchAddon?.clearActiveDecoration();
368
+ }
369
+ getFont() {
370
+ return this._configHelper.getFont(this._core);
371
+ }
372
+ getLongestViewportWrappedLineLength() {
373
+ let maxLineLength = 0;
374
+ for (let i = this.raw.buffer.active.length - 1; i >= this.raw.buffer.active.viewportY; i--) {
375
+ const lineInfo = this._getWrappedLineCount(i, this.raw.buffer.active);
376
+ maxLineLength = Math.max(maxLineLength, ((lineInfo.lineCount * this.raw.cols) - lineInfo.endSpaces) || 0);
377
+ i = lineInfo.currentIndex;
378
+ }
379
+ return maxLineLength;
380
+ }
381
+ _getWrappedLineCount(index, buffer) {
382
+ let line = buffer.getLine(index);
383
+ if (!line) {
384
+ throw new Error('Could not get line');
385
+ }
386
+ let currentIndex = index;
387
+ let endSpaces = 0;
388
+ for (let i = Math.min(line.length, this.raw.cols) - 1; i >= 0; i--) {
389
+ if (!line?.getCell(i)?.getChars()) {
390
+ endSpaces++;
391
+ }
392
+ else {
393
+ break;
394
+ }
395
+ }
396
+ while (line?.isWrapped && currentIndex > 0) {
397
+ currentIndex--;
398
+ line = buffer.getLine(currentIndex);
399
+ }
400
+ return { lineCount: index - currentIndex + 1, currentIndex, endSpaces };
401
+ }
402
+ scrollDownLine() {
403
+ this.raw.scrollLines(1);
404
+ }
405
+ scrollDownPage() {
406
+ this.raw.scrollPages(1);
407
+ }
408
+ scrollToBottom() {
409
+ this.raw.scrollToBottom();
410
+ }
411
+ scrollUpLine() {
412
+ this.raw.scrollLines(-1);
413
+ }
414
+ scrollUpPage() {
415
+ this.raw.scrollPages(-1);
416
+ }
417
+ scrollToTop() {
418
+ this.raw.scrollToTop();
419
+ }
420
+ clearBuffer() {
421
+ this.raw.clear();
422
+ this._capabilities.get(2 )?.handlePromptStart();
423
+ this._capabilities.get(2 )?.handleCommandStart();
424
+ }
425
+ hasSelection() {
426
+ return this.raw.hasSelection();
427
+ }
428
+ clearSelection() {
429
+ this.raw.clearSelection();
430
+ }
431
+ selectMarkedRange(fromMarkerId, toMarkerId, scrollIntoView = false) {
432
+ const detectionCapability = this.shellIntegration.capabilities.get(4 );
433
+ if (!detectionCapability) {
434
+ return;
435
+ }
436
+ const start = detectionCapability.getMark(fromMarkerId);
437
+ const end = detectionCapability.getMark(toMarkerId);
438
+ if (start === undefined || end === undefined) {
439
+ return;
440
+ }
441
+ this.raw.selectLines(start.line, end.line);
442
+ if (scrollIntoView) {
443
+ this.raw.scrollToLine(start.line);
444
+ }
445
+ }
446
+ selectAll() {
447
+ this.raw.focus();
448
+ this.raw.selectAll();
449
+ }
450
+ focus() {
451
+ this.raw.focus();
452
+ }
453
+ async copySelection(asHtml, command) {
454
+ if (this.hasSelection() || (asHtml && command)) {
455
+ if (asHtml) {
456
+ const textAsHtml = await this.getSelectionAsHtml(command);
457
+ function listener(e) {
458
+ if (!e.clipboardData.types.includes('text/plain')) {
459
+ e.clipboardData.setData('text/plain', command?.getOutput() ?? '');
460
+ }
461
+ e.clipboardData.setData('text/html', textAsHtml);
462
+ e.preventDefault();
463
+ }
464
+ document.addEventListener('copy', listener);
465
+ document.execCommand('copy');
466
+ document.removeEventListener('copy', listener);
467
+ }
468
+ else {
469
+ await this._clipboardService.writeText(this.raw.getSelection());
470
+ }
471
+ }
472
+ else {
473
+ this._notificationService.warn(( localizeWithPath(
474
+ 'vs/workbench/contrib/terminal/browser/xterm/xtermTerminal',
475
+ 'terminal.integrated.copySelection.noSelection',
476
+ 'The terminal has no selection to copy'
477
+ )));
478
+ }
479
+ }
480
+ _setCursorBlink(blink) {
481
+ if (this.raw.options.cursorBlink !== blink) {
482
+ this.raw.options.cursorBlink = blink;
483
+ this.raw.refresh(0, this.raw.rows - 1);
484
+ }
485
+ }
486
+ _setCursorStyle(style) {
487
+ const mapped = vscodeToXtermCursorStyle(style);
488
+ if (this.raw.options.cursorStyle !== mapped) {
489
+ this.raw.options.cursorStyle = mapped;
490
+ }
491
+ }
492
+ _setCursorStyleInactive(style) {
493
+ const mapped = vscodeToXtermCursorStyle(style);
494
+ if (this.raw.options.cursorInactiveStyle !== mapped) {
495
+ this.raw.options.cursorInactiveStyle = mapped;
496
+ }
497
+ }
498
+ _setCursorWidth(width) {
499
+ if (this.raw.options.cursorWidth !== width) {
500
+ this.raw.options.cursorWidth = width;
501
+ }
502
+ }
503
+ async _enableWebglRenderer() {
504
+ if (!this.raw.element || this._webglAddon) {
505
+ return;
506
+ }
507
+ if (!XtermTerminal_1._checkedWebglCompatible) {
508
+ XtermTerminal_1._checkedWebglCompatible = true;
509
+ const checkCanvas = document.createElement('canvas');
510
+ const checkGl = checkCanvas.getContext('webgl2');
511
+ const debugInfo = checkGl?.getExtension('WEBGL_debug_renderer_info');
512
+ if (checkGl && debugInfo) {
513
+ const renderer = checkGl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
514
+ if (renderer.startsWith('ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero)')) {
515
+ this._disableWebglForThisSession();
516
+ return;
517
+ }
518
+ }
519
+ }
520
+ const Addon = await this._getWebglAddonConstructor();
521
+ this._webglAddon = ( new Addon());
522
+ this._disposeOfCanvasRenderer();
523
+ try {
524
+ this.raw.loadAddon(this._webglAddon);
525
+ this._logService.trace('Webgl was loaded');
526
+ this._webglAddon.onContextLoss(() => {
527
+ this._logService.info(`Webgl lost context, disposing of webgl renderer`);
528
+ this._disposeOfWebglRenderer();
529
+ });
530
+ this._refreshImageAddon();
531
+ }
532
+ catch (e) {
533
+ this._logService.warn(`Webgl could not be loaded. Falling back to the canvas renderer type.`, e);
534
+ const neverMeasureRenderTime = this._storageService.getBoolean("terminal.integrated.neverMeasureRenderTime" , -1 , false);
535
+ if (!neverMeasureRenderTime && this._configHelper.config.gpuAcceleration !== 'off') {
536
+ this._measureRenderTime();
537
+ }
538
+ this._disableWebglForThisSession();
539
+ }
540
+ }
541
+ _disableWebglForThisSession() {
542
+ XtermTerminal_1._suggestedRendererType = 'canvas';
543
+ this._disposeOfWebglRenderer();
544
+ this._enableCanvasRenderer();
545
+ }
546
+ async _enableCanvasRenderer() {
547
+ if (!this.raw.element || this._canvasAddon) {
548
+ return;
549
+ }
550
+ const Addon = await this._getCanvasAddonConstructor();
551
+ this._canvasAddon = ( new Addon());
552
+ this._disposeOfWebglRenderer();
553
+ try {
554
+ this.raw.loadAddon(this._canvasAddon);
555
+ this._logService.trace('Canvas renderer was loaded');
556
+ }
557
+ catch (e) {
558
+ this._logService.warn(`Canvas renderer could not be loaded, falling back to dom renderer`, e);
559
+ const neverMeasureRenderTime = this._storageService.getBoolean("terminal.integrated.neverMeasureRenderTime" , -1 , false);
560
+ if (!neverMeasureRenderTime && this._configHelper.config.gpuAcceleration !== 'off') {
561
+ this._measureRenderTime();
562
+ }
563
+ XtermTerminal_1._suggestedRendererType = 'dom';
564
+ this._disposeOfCanvasRenderer();
565
+ }
566
+ this._refreshImageAddon();
567
+ }
568
+ async _getCanvasAddonConstructor() {
569
+ if (!CanvasAddon) {
570
+ CanvasAddon = (await import('xterm-addon-canvas').then(module => module.default ?? module)).CanvasAddon;
571
+ }
572
+ return CanvasAddon;
573
+ }
574
+ async _refreshImageAddon() {
575
+ if (this._configHelper.config.enableImages && (this._canvasAddon || this._webglAddon)) {
576
+ if (!this._imageAddon) {
577
+ const AddonCtor = await this._getImageAddonConstructor();
578
+ this._imageAddon = ( new AddonCtor());
579
+ this.raw.loadAddon(this._imageAddon);
580
+ }
581
+ }
582
+ else {
583
+ try {
584
+ this._imageAddon?.dispose();
585
+ }
586
+ catch {
587
+ }
588
+ this._imageAddon = undefined;
589
+ }
590
+ }
591
+ async _getImageAddonConstructor() {
592
+ if (!ImageAddon) {
593
+ ImageAddon = (await import('xterm-addon-image').then(module => module.default ?? module)).ImageAddon;
594
+ }
595
+ return ImageAddon;
596
+ }
597
+ async _getSearchAddonConstructor() {
598
+ if (!SearchAddon) {
599
+ SearchAddon = (await import('xterm-addon-search').then(module => module.default ?? module)).SearchAddon;
600
+ }
601
+ return SearchAddon;
602
+ }
603
+ async _getUnicode11Constructor() {
604
+ if (!Unicode11Addon) {
605
+ Unicode11Addon = (await import('xterm-addon-unicode11').then(module => module.default ?? module)).Unicode11Addon;
606
+ }
607
+ return Unicode11Addon;
608
+ }
609
+ async _getWebglAddonConstructor() {
610
+ if (!WebglAddon) {
611
+ WebglAddon = (await import('xterm-addon-webgl').then(module => module.default ?? module)).WebglAddon;
612
+ }
613
+ return WebglAddon;
614
+ }
615
+ async _getSerializeAddonConstructor() {
616
+ if (!SerializeAddon) {
617
+ SerializeAddon = (await import('xterm-addon-serialize').then(module => module.default ?? module)).SerializeAddon;
618
+ }
619
+ return SerializeAddon;
620
+ }
621
+ _disposeOfCanvasRenderer() {
622
+ try {
623
+ this._canvasAddon?.dispose();
624
+ }
625
+ catch {
626
+ }
627
+ this._canvasAddon = undefined;
628
+ this._refreshImageAddon();
629
+ }
630
+ _disposeOfWebglRenderer() {
631
+ try {
632
+ this._webglAddon?.dispose();
633
+ }
634
+ catch {
635
+ }
636
+ this._webglAddon = undefined;
637
+ this._refreshImageAddon();
638
+ }
639
+ async _measureRenderTime() {
640
+ const frameTimes = [];
641
+ if (!this._core._renderService?._renderer._renderLayers) {
642
+ return;
643
+ }
644
+ const textRenderLayer = this._core._renderService._renderer._renderLayers[0];
645
+ const originalOnGridChanged = textRenderLayer?.onGridChanged;
646
+ const evaluateCanvasRenderer = () => {
647
+ frameTimes.shift();
648
+ const medianTime = frameTimes.sort((a, b) => a - b)[Math.floor(frameTimes.length / 2)];
649
+ if (medianTime > 50 ) {
650
+ if (this._configHelper.config.gpuAcceleration === 'auto') {
651
+ XtermTerminal_1._suggestedRendererType = 'dom';
652
+ this.updateConfig();
653
+ }
654
+ else {
655
+ const promptChoices = [
656
+ {
657
+ label: ( localizeWithPath('vs/workbench/contrib/terminal/browser/xterm/xtermTerminal', 'yes', "Yes")),
658
+ run: () => this._configurationService.updateValue("terminal.integrated.gpuAcceleration" , 'off', 2 )
659
+ },
660
+ {
661
+ label: ( localizeWithPath('vs/workbench/contrib/terminal/browser/xterm/xtermTerminal', 'no', "No")),
662
+ run: () => { }
663
+ },
664
+ {
665
+ label: ( localizeWithPath(
666
+ 'vs/workbench/contrib/terminal/browser/xterm/xtermTerminal',
667
+ 'dontShowAgain',
668
+ "Don't Show Again"
669
+ )),
670
+ isSecondary: true,
671
+ run: () => this._storageService.store("terminal.integrated.neverMeasureRenderTime" , true, -1 , 1 )
672
+ }
673
+ ];
674
+ this._notificationService.prompt(Severity.Warning, ( localizeWithPath(
675
+ 'vs/workbench/contrib/terminal/browser/xterm/xtermTerminal',
676
+ 'terminal.slowRendering',
677
+ 'Terminal GPU acceleration appears to be slow on your computer. Would you like to switch to disable it which may improve performance? [Read more about terminal settings](https://code.visualstudio.com/docs/editor/integrated-terminal#_changing-how-the-terminal-is-rendered).'
678
+ )), promptChoices);
679
+ }
680
+ }
681
+ };
682
+ textRenderLayer.onGridChanged = (terminal, firstRow, lastRow) => {
683
+ const startTime = performance.now();
684
+ originalOnGridChanged.call(textRenderLayer, terminal, firstRow, lastRow);
685
+ frameTimes.push(performance.now() - startTime);
686
+ if (frameTimes.length === 20 ) {
687
+ evaluateCanvasRenderer();
688
+ textRenderLayer.onGridChanged = originalOnGridChanged;
689
+ }
690
+ };
691
+ }
692
+ _getXtermTheme(theme) {
693
+ if (!theme) {
694
+ theme = this._themeService.getColorTheme();
695
+ }
696
+ const foregroundColor = theme.getColor(TERMINAL_FOREGROUND_COLOR);
697
+ const backgroundColor = this._backgroundColorProvider.getBackgroundColor(theme);
698
+ const cursorColor = theme.getColor(TERMINAL_CURSOR_FOREGROUND_COLOR) || foregroundColor;
699
+ const cursorAccentColor = theme.getColor(TERMINAL_CURSOR_BACKGROUND_COLOR) || backgroundColor;
700
+ const selectionBackgroundColor = theme.getColor(TERMINAL_SELECTION_BACKGROUND_COLOR);
701
+ const selectionInactiveBackgroundColor = theme.getColor(TERMINAL_INACTIVE_SELECTION_BACKGROUND_COLOR);
702
+ const selectionForegroundColor = theme.getColor(TERMINAL_SELECTION_FOREGROUND_COLOR) || undefined;
703
+ return {
704
+ background: backgroundColor?.toString(),
705
+ foreground: foregroundColor?.toString(),
706
+ cursor: cursorColor?.toString(),
707
+ cursorAccent: cursorAccentColor?.toString(),
708
+ selectionBackground: selectionBackgroundColor?.toString(),
709
+ selectionInactiveBackground: selectionInactiveBackgroundColor?.toString(),
710
+ selectionForeground: selectionForegroundColor?.toString(),
711
+ black: theme.getColor(ansiColorIdentifiers[0])?.toString(),
712
+ red: theme.getColor(ansiColorIdentifiers[1])?.toString(),
713
+ green: theme.getColor(ansiColorIdentifiers[2])?.toString(),
714
+ yellow: theme.getColor(ansiColorIdentifiers[3])?.toString(),
715
+ blue: theme.getColor(ansiColorIdentifiers[4])?.toString(),
716
+ magenta: theme.getColor(ansiColorIdentifiers[5])?.toString(),
717
+ cyan: theme.getColor(ansiColorIdentifiers[6])?.toString(),
718
+ white: theme.getColor(ansiColorIdentifiers[7])?.toString(),
719
+ brightBlack: theme.getColor(ansiColorIdentifiers[8])?.toString(),
720
+ brightRed: theme.getColor(ansiColorIdentifiers[9])?.toString(),
721
+ brightGreen: theme.getColor(ansiColorIdentifiers[10])?.toString(),
722
+ brightYellow: theme.getColor(ansiColorIdentifiers[11])?.toString(),
723
+ brightBlue: theme.getColor(ansiColorIdentifiers[12])?.toString(),
724
+ brightMagenta: theme.getColor(ansiColorIdentifiers[13])?.toString(),
725
+ brightCyan: theme.getColor(ansiColorIdentifiers[14])?.toString(),
726
+ brightWhite: theme.getColor(ansiColorIdentifiers[15])?.toString()
727
+ };
728
+ }
729
+ _updateTheme(theme) {
730
+ this.raw.options.theme = this._getXtermTheme(theme);
731
+ }
732
+ refresh() {
733
+ this._updateTheme();
734
+ this._decorationAddon.refreshLayouts();
735
+ }
736
+ async _updateUnicodeVersion() {
737
+ if (!this._unicode11Addon && this._configHelper.config.unicodeVersion === '11') {
738
+ const Addon = await this._getUnicode11Constructor();
739
+ this._unicode11Addon = ( new Addon());
740
+ this.raw.loadAddon(this._unicode11Addon);
741
+ }
742
+ if (this.raw.unicode.activeVersion !== this._configHelper.config.unicodeVersion) {
743
+ this.raw.unicode.activeVersion = this._configHelper.config.unicodeVersion;
744
+ }
745
+ }
746
+ _writeText(data) {
747
+ this.raw.write(data);
748
+ }
749
+ dispose() {
750
+ this._anyTerminalFocusContextKey.reset();
751
+ this._anyFocusedTerminalHasSelection.reset();
752
+ this._onDidDispose.fire();
753
+ super.dispose();
754
+ }
755
+ };
756
+ XtermTerminal.__decorator = ( __decorate([
757
+ debounce(100)
758
+ ], XtermTerminal.prototype, "_refreshImageAddon", null));
759
+ XtermTerminal = XtermTerminal_1 = ( __decorate([
760
+ ( __param(9, IConfigurationService)),
761
+ ( __param(10, IInstantiationService)),
762
+ ( __param(11, ITerminalLogService)),
763
+ ( __param(12, INotificationService)),
764
+ ( __param(13, IStorageService)),
765
+ ( __param(14, IThemeService)),
766
+ ( __param(15, ITelemetryService)),
767
+ ( __param(16, IClipboardService)),
768
+ ( __param(17, IContextKeyService))
769
+ ], XtermTerminal));
770
+ function getXtermScaledDimensions(font, width, height) {
771
+ if (!font.charWidth || !font.charHeight) {
772
+ return null;
773
+ }
774
+ const scaledWidthAvailable = width * window.devicePixelRatio;
775
+ const scaledCharWidth = font.charWidth * window.devicePixelRatio + font.letterSpacing;
776
+ const cols = Math.max(Math.floor(scaledWidthAvailable / scaledCharWidth), 1);
777
+ const scaledHeightAvailable = height * window.devicePixelRatio;
778
+ const scaledCharHeight = Math.ceil(font.charHeight * window.devicePixelRatio);
779
+ const scaledLineHeight = Math.floor(scaledCharHeight * font.lineHeight);
780
+ const rows = Math.max(Math.floor(scaledHeightAvailable / scaledLineHeight), 1);
781
+ return { rows, cols };
782
+ }
783
+ function vscodeToXtermLogLevel(logLevel) {
784
+ switch (logLevel) {
785
+ case LogLevel.Trace: return 'trace';
786
+ case LogLevel.Debug: return 'debug';
787
+ case LogLevel.Info: return 'info';
788
+ case LogLevel.Warning: return 'warn';
789
+ case LogLevel.Error: return 'error';
790
+ default: return 'off';
791
+ }
792
+ }
793
+ function vscodeToXtermCursorStyle(style) {
794
+ if (style === 'line') {
795
+ return 'bar';
796
+ }
797
+ return style;
798
+ }
799
+ export { XtermTerminal, getXtermScaledDimensions };