@codingame/monaco-vscode-xterm-addons-common 25.1.2 → 26.0.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.
Files changed (18) hide show
  1. package/package.json +10 -10
  2. package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatContext.js +58 -114
  3. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatDynamicVariables.d.ts +42 -0
  4. package/vscode/src/vs/workbench/contrib/chat/browser/attachments/chatDynamicVariables.js +209 -0
  5. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/attachInstructionsAction.js +18 -16
  6. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.d.ts +1 -0
  7. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/newPromptFileActions.js +151 -70
  8. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptName.js +27 -25
  9. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/askForPromptSourceFolder.js +67 -53
  10. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.d.ts +4 -1
  11. package/vscode/src/vs/workbench/contrib/chat/browser/promptSyntax/pickers/promptFilePickers.js +188 -116
  12. package/vscode/src/vs/workbench/contrib/chat/browser/widget/input/editor/chatPasteProviders.js +106 -71
  13. package/vscode/src/vs/workbench/contrib/terminal/browser/terminalUri.js +6 -3
  14. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.js +204 -140
  15. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/markNavigationAddon.js +77 -82
  16. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermAddonImporter.js +24 -24
  17. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.d.ts +4 -1
  18. package/vscode/src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.js +262 -162
@@ -42,17 +42,20 @@ import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/quic
42
42
  import '@codingame/monaco-vscode-api/vscode/vs/platform/theme/common/colors/searchColors';
43
43
  import { XtermAddonImporter } from './xtermAddonImporter.js';
44
44
  import { equals } from '@codingame/monaco-vscode-api/vscode/vs/base/common/objects';
45
- import { assert } from '@codingame/monaco-vscode-api/vscode/vs/base/common/assert';
45
+ import { isNumber } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
46
46
 
47
47
  var XtermTerminal_1;
48
48
  var RenderConstants;
49
- (function (RenderConstants) {
49
+ (function(RenderConstants) {
50
50
  RenderConstants[RenderConstants["SmoothScrollDuration"] = 125] = "SmoothScrollDuration";
51
51
  })(RenderConstants || (RenderConstants = {}));
52
52
  function getFullBufferLineAsString(lineIndex, buffer) {
53
53
  let line = buffer.getLine(lineIndex);
54
54
  if (!line) {
55
- return { lineData: undefined, lineIndex };
55
+ return {
56
+ lineData: undefined,
57
+ lineIndex
58
+ };
56
59
  }
57
60
  let lineData = line.translateToString(true);
58
61
  while (lineIndex > 0 && line.isWrapped) {
@@ -62,19 +65,48 @@ function getFullBufferLineAsString(lineIndex, buffer) {
62
65
  }
63
66
  lineData = line.translateToString(false) + lineData;
64
67
  }
65
- return { lineData, lineIndex };
68
+ return {
69
+ lineData,
70
+ lineIndex
71
+ };
66
72
  }
67
73
  let XtermTerminal = class XtermTerminal extends Disposable {
68
- static { XtermTerminal_1 = this; }
69
- static { this._suggestedRendererType = undefined; }
70
- get lastInputEvent() { return this._lastInputEvent; }
71
- get progressState() { return this._progressState; }
72
- get findResult() { return this._lastFindResult; }
73
- get isStdinDisabled() { return !!this.raw.options.disableStdin; }
74
- get isGpuAccelerated() { return !!this._webglAddon; }
75
- get markTracker() { return this._markNavigationAddon; }
76
- get shellIntegration() { return this._shellIntegrationAddon; }
77
- get decorationAddon() { return this._decorationAddon; }
74
+ static {
75
+ XtermTerminal_1 = this;
76
+ }
77
+ static {
78
+ this._suggestedRendererType = undefined;
79
+ }
80
+ get lastInputEvent() {
81
+ return this._lastInputEvent;
82
+ }
83
+ get progressState() {
84
+ return this._progressState;
85
+ }
86
+ get buffer() {
87
+ return this.raw.buffer;
88
+ }
89
+ get cols() {
90
+ return this.raw.cols;
91
+ }
92
+ get findResult() {
93
+ return this._lastFindResult;
94
+ }
95
+ get isStdinDisabled() {
96
+ return !!this.raw.options.disableStdin;
97
+ }
98
+ get isGpuAccelerated() {
99
+ return !!this._webglAddon;
100
+ }
101
+ get markTracker() {
102
+ return this._markNavigationAddon;
103
+ }
104
+ get shellIntegration() {
105
+ return this._shellIntegrationAddon;
106
+ }
107
+ get decorationAddon() {
108
+ return this._decorationAddon;
109
+ }
78
110
  get textureAtlas() {
79
111
  const canvas = this._webglAddon?.textureAtlas;
80
112
  if (!canvas) {
@@ -88,7 +120,23 @@ let XtermTerminal = class XtermTerminal extends Disposable {
88
120
  }
89
121
  return isAncestorOfActiveElement(this.raw.element);
90
122
  }
91
- constructor(resource, xtermCtor, options, _onDidExecuteText, _configurationService, _instantiationService, _logService, _notificationService, _themeService, _telemetryService, _terminalConfigurationService, _clipboardService, contextKeyService, _accessibilitySignalService, layoutService) {
123
+ constructor(
124
+ resource,
125
+ xtermCtor,
126
+ options,
127
+ _onDidExecuteText,
128
+ _configurationService,
129
+ _instantiationService,
130
+ _logService,
131
+ _notificationService,
132
+ _themeService,
133
+ _telemetryService,
134
+ _terminalConfigurationService,
135
+ _clipboardService,
136
+ contextKeyService,
137
+ _accessibilitySignalService,
138
+ layoutService
139
+ ) {
92
140
  super();
93
141
  this._onDidExecuteText = _onDidExecuteText;
94
142
  this._configurationService = _configurationService;
@@ -101,7 +149,10 @@ let XtermTerminal = class XtermTerminal extends Disposable {
101
149
  this._clipboardService = _clipboardService;
102
150
  this._accessibilitySignalService = _accessibilitySignalService;
103
151
  this._isPhysicalMouseWheel = MouseWheelClassifier.INSTANCE.isPhysicalMouseWheel();
104
- this._progressState = { state: 0, value: 0 };
152
+ this._progressState = {
153
+ state: 0,
154
+ value: 0
155
+ };
105
156
  this._webglAddonCustomGlyphs = false;
106
157
  this._ligaturesAddon = this._register(( new MutableDisposable()));
107
158
  this._attachedDisposables = this._register(( new DisposableStore()));
@@ -130,13 +181,13 @@ let XtermTerminal = class XtermTerminal extends Disposable {
130
181
  this._capabilities = options.capabilities;
131
182
  const font = this._terminalConfigurationService.getFont(getActiveWindow(), undefined, true);
132
183
  const config = this._terminalConfigurationService.config;
133
- const editorOptions = this._configurationService.getValue('editor');
184
+ const editorOptions = this._configurationService.getValue("editor");
134
185
  this.raw = this._register(( new xtermCtor({
135
186
  allowProposedApi: true,
136
187
  cols: options.cols,
137
188
  rows: options.rows,
138
189
  documentOverride: layoutService.mainContainer.ownerDocument,
139
- altClickMovesCursor: config.altClickMovesCursor && editorOptions.multiCursorModifier === 'alt',
190
+ altClickMovesCursor: config.altClickMovesCursor && editorOptions.multiCursorModifier === "alt",
140
191
  scrollback: config.scrollback,
141
192
  theme: this.getXtermTheme(),
142
193
  drawBoldTextInBrightColors: config.drawBoldTextInBrightColors,
@@ -156,30 +207,36 @@ let XtermTerminal = class XtermTerminal extends Disposable {
156
207
  cursorWidth: config.cursorWidth,
157
208
  macOptionIsMeta: config.macOptionIsMeta,
158
209
  macOptionClickForcesSelection: config.macOptionClickForcesSelection,
159
- rightClickSelectsWord: config.rightClickBehavior === 'selectWord',
210
+ rightClickSelectsWord: config.rightClickBehavior === "selectWord",
160
211
  fastScrollSensitivity: config.fastScrollSensitivity,
161
212
  scrollSensitivity: config.mouseWheelScrollSensitivity,
162
213
  scrollOnEraseInDisplay: true,
163
214
  wordSeparator: config.wordSeparators,
164
- overviewRuler: options.disableOverviewRuler ? { width: 0 } : {
215
+ overviewRuler: options.disableOverviewRuler ? {
216
+ width: 0
217
+ } : {
165
218
  width: 14,
166
- showTopBorder: true,
219
+ showTopBorder: true
167
220
  },
168
221
  ignoreBracketedPasteMode: config.ignoreBracketedPasteMode,
169
222
  rescaleOverlappingGlyphs: config.rescaleOverlappingGlyphs,
223
+ vtExtensions: {
224
+ kittyKeyboard: config.enableKittyKeyboardProtocol,
225
+ win32InputMode: config.enableWin32InputMode
226
+ },
170
227
  windowOptions: {
171
228
  getWinSizePixels: true,
172
229
  getCellSizePixels: true,
173
- getWinSizeChars: true,
174
- },
230
+ getWinSizeChars: true
231
+ }
175
232
  })));
176
233
  this._updateSmoothScrolling();
177
234
  this._core = this.raw._core;
178
- this._register(this._configurationService.onDidChangeConfiguration(async (e) => {
235
+ this._register(this._configurationService.onDidChangeConfiguration(async e => {
179
236
  if (e.affectsConfiguration(TerminalSettingId.GpuAcceleration)) {
180
237
  XtermTerminal_1._suggestedRendererType = undefined;
181
238
  }
182
- if (e.affectsConfiguration('terminal.integrated') || e.affectsConfiguration('editor.fastScrollSensitivity') || e.affectsConfiguration('editor.mouseWheelScrollSensitivity') || e.affectsConfiguration('editor.multiCursorModifier')) {
239
+ if (e.affectsConfiguration("terminal.integrated") || e.affectsConfiguration("editor.fastScrollSensitivity") || e.affectsConfiguration("editor.mouseWheelScrollSensitivity") || e.affectsConfiguration("editor.multiCursorModifier")) {
183
240
  this.updateConfig();
184
241
  }
185
242
  if (e.affectsConfiguration(TerminalSettingId.UnicodeVersion)) {
@@ -189,8 +246,12 @@ let XtermTerminal = class XtermTerminal extends Disposable {
189
246
  this._updateTheme();
190
247
  }
191
248
  }));
192
- this._register(this._themeService.onDidColorThemeChange(theme => this._updateTheme(theme)));
193
- this._register(this._logService.onDidChangeLogLevel(e => this.raw.options.logLevel = vscodeToXtermLogLevel(e)));
249
+ this._register(
250
+ this._themeService.onDidColorThemeChange(theme => this._updateTheme(theme))
251
+ );
252
+ this._register(
253
+ this._logService.onDidChangeLogLevel(e => this.raw.options.logLevel = vscodeToXtermLogLevel(e))
254
+ );
194
255
  this._register(this.raw.onSelectionChange(() => {
195
256
  this._onDidChangeSelection.fire();
196
257
  if (this.isFocused) {
@@ -202,32 +263,36 @@ let XtermTerminal = class XtermTerminal extends Disposable {
202
263
  this._markNavigationAddon = this._instantiationService.createInstance(MarkNavigationAddon, options.capabilities);
203
264
  this.raw.loadAddon(this._markNavigationAddon);
204
265
  this._decorationAddon = this._instantiationService.createInstance(DecorationAddon, resource, this._capabilities);
205
- this._register(this._decorationAddon.onDidRequestRunCommand(e => this._onDidRequestRunCommand.fire(e)));
206
- this._register(this._decorationAddon.onDidRequestCopyAsHtml(e => this._onDidRequestCopyAsHtml.fire(e)));
266
+ this._register(
267
+ this._decorationAddon.onDidRequestRunCommand(e => this._onDidRequestRunCommand.fire(e))
268
+ );
269
+ this._register(
270
+ this._decorationAddon.onDidRequestCopyAsHtml(e => this._onDidRequestCopyAsHtml.fire(e))
271
+ );
207
272
  this.raw.loadAddon(this._decorationAddon);
208
273
  this._shellIntegrationAddon = ( new ShellIntegrationAddon(
209
- options.shellIntegrationNonce ?? '',
274
+ options.shellIntegrationNonce ?? "",
210
275
  options.disableShellIntegrationReporting,
211
276
  this._onDidExecuteText,
212
277
  this._telemetryService,
213
278
  this._logService
214
279
  ));
215
280
  this.raw.loadAddon(this._shellIntegrationAddon);
216
- this._xtermAddonLoader.importAddon('clipboard').then(ClipboardAddon => {
281
+ this._xtermAddonLoader.importAddon("clipboard").then(ClipboardAddon => {
217
282
  if (this._store.isDisposed) {
218
283
  return;
219
284
  }
220
285
  this._clipboardAddon = this._instantiationService.createInstance(ClipboardAddon, undefined, {
221
286
  async readText(type) {
222
- return _clipboardService.readText(type === 'p' ? 'selection' : 'clipboard');
287
+ return _clipboardService.readText(type === "p" ? "selection" : "clipboard");
223
288
  },
224
289
  async writeText(type, text) {
225
- return _clipboardService.writeText(text, type === 'p' ? 'selection' : 'clipboard');
290
+ return _clipboardService.writeText(text, type === "p" ? "selection" : "clipboard");
226
291
  }
227
292
  });
228
293
  this.raw.loadAddon(this._clipboardAddon);
229
294
  });
230
- this._xtermAddonLoader.importAddon('progress').then(ProgressAddon => {
295
+ this._xtermAddonLoader.importAddon("progress").then(ProgressAddon => {
231
296
  if (this._store.isDisposed) {
232
297
  return;
233
298
  }
@@ -243,12 +308,17 @@ let XtermTerminal = class XtermTerminal extends Disposable {
243
308
  updateProgress();
244
309
  const commandDetection = this._capabilities.get(TerminalCapability.CommandDetection);
245
310
  if (commandDetection) {
246
- this._register(commandDetection.onCommandFinished(() => progressAddon.progress = { state: 0, value: 0 }));
247
- }
248
- else {
311
+ this._register(commandDetection.onCommandFinished(() => progressAddon.progress = {
312
+ state: 0,
313
+ value: 0
314
+ }));
315
+ } else {
249
316
  const disposable = this._capabilities.onDidAddCapability(e => {
250
317
  if (e.id === TerminalCapability.CommandDetection) {
251
- this._register(e.capability.onCommandFinished(() => progressAddon.progress = { state: 0, value: 0 }));
318
+ this._register(e.capability.onCommandFinished(() => progressAddon.progress = {
319
+ state: 0,
320
+ value: 0
321
+ }));
252
322
  this._store.delete(disposable);
253
323
  }
254
324
  });
@@ -260,7 +330,10 @@ let XtermTerminal = class XtermTerminal extends Disposable {
260
330
  }
261
331
  *getBufferReverseIterator() {
262
332
  for (let i = this.raw.buffer.active.length - 1; i >= 0; i--) {
263
- const { lineData, lineIndex } = getFullBufferLineAsString(i, this.raw.buffer.active);
333
+ const {
334
+ lineData,
335
+ lineIndex
336
+ } = getFullBufferLineAsString(i, this.raw.buffer.active);
264
337
  if (lineData) {
265
338
  i = lineIndex;
266
339
  yield lineData;
@@ -271,21 +344,21 @@ let XtermTerminal = class XtermTerminal extends Disposable {
271
344
  const lines = [];
272
345
  const buffer = this.raw.buffer.active;
273
346
  if (startMarker?.line === -1) {
274
- throw ( new Error('Cannot get contents of a disposed startMarker'));
347
+ throw ( new Error("Cannot get contents of a disposed startMarker"));
275
348
  }
276
349
  if (endMarker?.line === -1) {
277
- throw ( new Error('Cannot get contents of a disposed endMarker'));
350
+ throw ( new Error("Cannot get contents of a disposed endMarker"));
278
351
  }
279
352
  const startLine = startMarker?.line ?? 0;
280
353
  const endLine = endMarker?.line ?? buffer.length - 1;
281
354
  for (let y = startLine; y <= endLine; y++) {
282
- lines.push(buffer.getLine(y)?.translateToString(true) ?? '');
355
+ lines.push(buffer.getLine(y)?.translateToString(true) ?? "");
283
356
  }
284
- return lines.join('\n');
357
+ return lines.join("\n");
285
358
  }
286
359
  async getContentsAsHtml() {
287
360
  if (!this._serializeAddon) {
288
- const Addon = await this._xtermAddonLoader.importAddon('serialize');
361
+ const Addon = await this._xtermAddonLoader.importAddon("serialize");
289
362
  this._serializeAddon = ( new Addon());
290
363
  this.raw.loadAddon(this._serializeAddon);
291
364
  }
@@ -293,7 +366,7 @@ let XtermTerminal = class XtermTerminal extends Disposable {
293
366
  }
294
367
  async getCommandOutputAsHtml(command, maxLines) {
295
368
  if (!this._serializeAddon) {
296
- const Addon = await this._xtermAddonLoader.importAddon('serialize');
369
+ const Addon = await this._xtermAddonLoader.importAddon("serialize");
297
370
  this._serializeAddon = ( new Addon());
298
371
  this.raw.loadAddon(this._serializeAddon);
299
372
  }
@@ -302,22 +375,23 @@ let XtermTerminal = class XtermTerminal extends Disposable {
302
375
  if (command.executedMarker && command.executedMarker.line >= 0) {
303
376
  startLine = command.executedMarker.line;
304
377
  startCol = Math.max(command.executedX ?? 0, 0);
305
- }
306
- else {
378
+ } else {
307
379
  startLine = command.marker?.line !== undefined ? command.marker.line + 1 : 1;
308
380
  startCol = Math.max(command.startX ?? 0, 0);
309
381
  }
310
382
  let endLine = command.endMarker?.line !== undefined ? command.endMarker.line - 1 : this.raw.buffer.active.length - 1;
311
383
  if (endLine < startLine) {
312
- return { text: '', truncated: false };
384
+ return {
385
+ text: "",
386
+ truncated: false
387
+ };
313
388
  }
314
389
  let emptyLinesFromEnd = 0;
315
390
  for (let i = endLine; i >= startLine; i--) {
316
391
  const line = this.raw.buffer.active.getLine(i);
317
- if (line && line.translateToString(true).trim() === '') {
392
+ if (line && line.translateToString(true).trim() === "") {
318
393
  emptyLinesFromEnd++;
319
- }
320
- else {
394
+ } else {
321
395
  break;
322
396
  }
323
397
  }
@@ -325,13 +399,12 @@ let XtermTerminal = class XtermTerminal extends Disposable {
325
399
  let emptyLinesFromStart = 0;
326
400
  for (let i = startLine; i <= endLine; i++) {
327
401
  const line = this.raw.buffer.active.getLine(i);
328
- if (line && line.translateToString(true, i === startLine ? startCol : undefined).trim() === '') {
402
+ if (line && line.translateToString(true, i === startLine ? startCol : undefined).trim() === "") {
329
403
  if (i === startLine) {
330
404
  startCol = 0;
331
405
  }
332
406
  emptyLinesFromStart++;
333
- }
334
- else {
407
+ } else {
335
408
  break;
336
409
  }
337
410
  }
@@ -344,13 +417,22 @@ let XtermTerminal = class XtermTerminal extends Disposable {
344
417
  if (bufferLine) {
345
418
  startCol = Math.min(startCol, bufferLine.length);
346
419
  }
347
- const range = { startLine, endLine, startCol };
348
- const result = this._serializeAddon.serializeAsHTML({ range });
349
- return { text: result, truncated: (endLine - startLine) >= maxLines };
420
+ const range = {
421
+ startLine,
422
+ endLine,
423
+ startCol
424
+ };
425
+ const result = this._serializeAddon.serializeAsHTML({
426
+ range
427
+ });
428
+ return {
429
+ text: result,
430
+ truncated: (endLine - startLine) >= maxLines
431
+ };
350
432
  }
351
433
  async getSelectionAsHtml(command) {
352
434
  if (!this._serializeAddon) {
353
- const Addon = await this._xtermAddonLoader.importAddon('serialize');
435
+ const Addon = await this._xtermAddonLoader.importAddon("serialize");
354
436
  this._serializeAddon = ( new Addon());
355
437
  this.raw.loadAddon(this._serializeAddon);
356
438
  }
@@ -362,14 +444,19 @@ let XtermTerminal = class XtermTerminal extends Disposable {
362
444
  }
363
445
  this.raw.select(0, row + 1, length - Math.floor(length / this.raw.cols));
364
446
  }
365
- const result = this._serializeAddon.serializeAsHTML({ onlySelection: true });
447
+ const result = this._serializeAddon.serializeAsHTML({
448
+ onlySelection: true
449
+ });
366
450
  if (command) {
367
451
  this.raw.clearSelection();
368
452
  }
369
453
  return result;
370
454
  }
371
455
  attachToElement(container, partialOptions) {
372
- const options = { enableGpu: true, ...partialOptions };
456
+ const options = {
457
+ enableGpu: true,
458
+ ...partialOptions
459
+ };
373
460
  if (!this._attached) {
374
461
  this.raw.open(container);
375
462
  }
@@ -379,25 +466,38 @@ let XtermTerminal = class XtermTerminal extends Disposable {
379
466
  }
380
467
  }
381
468
  if (!this.raw.element || !this.raw.textarea) {
382
- throw ( new Error('xterm elements not set after open'));
469
+ throw ( new Error("xterm elements not set after open"));
383
470
  }
384
471
  const ad = this._attachedDisposables;
385
472
  ad.clear();
386
- ad.add(addDisposableListener(this.raw.textarea, 'focus', () => this._setFocused(true)));
387
- ad.add(addDisposableListener(this.raw.textarea, 'blur', () => this._setFocused(false)));
388
- ad.add(addDisposableListener(this.raw.textarea, 'focusout', () => this._setFocused(false)));
389
- ad.add(addDisposableListener(this.raw.element, EventType.MOUSE_WHEEL, (e) => {
390
- const classifier = MouseWheelClassifier.INSTANCE;
391
- classifier.acceptStandardWheelEvent(( new StandardWheelEvent(e)));
392
- const value = classifier.isPhysicalMouseWheel();
393
- if (value !== this._isPhysicalMouseWheel) {
394
- this._isPhysicalMouseWheel = value;
395
- this._updateSmoothScrolling();
396
- }
397
- }, { passive: true }));
473
+ ad.add(
474
+ addDisposableListener(this.raw.textarea, "focus", () => this._setFocused(true))
475
+ );
476
+ ad.add(
477
+ addDisposableListener(this.raw.textarea, "blur", () => this._setFocused(false))
478
+ );
479
+ ad.add(
480
+ addDisposableListener(this.raw.textarea, "focusout", () => this._setFocused(false))
481
+ );
482
+ ad.add(
483
+ addDisposableListener(this.raw.element, EventType.MOUSE_WHEEL, e => {
484
+ const classifier = MouseWheelClassifier.INSTANCE;
485
+ classifier.acceptStandardWheelEvent(( new StandardWheelEvent(e)));
486
+ const value = classifier.isPhysicalMouseWheel();
487
+ if (value !== this._isPhysicalMouseWheel) {
488
+ this._isPhysicalMouseWheel = value;
489
+ this._updateSmoothScrolling();
490
+ }
491
+ }, {
492
+ passive: true
493
+ })
494
+ );
398
495
  this._refreshLigaturesAddon();
399
- this._attached = { container, options };
400
- return this._attached?.container.querySelector('.xterm-screen');
496
+ this._attached = {
497
+ container,
498
+ options
499
+ };
500
+ return this._attached?.container.querySelector(".xterm-screen");
401
501
  }
402
502
  _setFocused(isFocused) {
403
503
  this._onDidChangeFocus.fire(isFocused);
@@ -408,7 +508,7 @@ let XtermTerminal = class XtermTerminal extends Disposable {
408
508
  this.raw.write(data, callback);
409
509
  }
410
510
  resize(columns, rows) {
411
- this._logService.debug('resizing', columns, rows);
511
+ this._logService.debug("resizing", columns, rows);
412
512
  this.raw.resize(columns, rows);
413
513
  }
414
514
  updateConfig() {
@@ -425,20 +525,23 @@ let XtermTerminal = class XtermTerminal extends Disposable {
425
525
  this.raw.options.fastScrollSensitivity = config.fastScrollSensitivity;
426
526
  this.raw.options.scrollSensitivity = config.mouseWheelScrollSensitivity;
427
527
  this.raw.options.macOptionIsMeta = config.macOptionIsMeta;
428
- const editorOptions = this._configurationService.getValue('editor');
429
- this.raw.options.altClickMovesCursor = config.altClickMovesCursor && editorOptions.multiCursorModifier === 'alt';
528
+ const editorOptions = this._configurationService.getValue("editor");
529
+ this.raw.options.altClickMovesCursor = config.altClickMovesCursor && editorOptions.multiCursorModifier === "alt";
430
530
  this.raw.options.macOptionClickForcesSelection = config.macOptionClickForcesSelection;
431
- this.raw.options.rightClickSelectsWord = config.rightClickBehavior === 'selectWord';
531
+ this.raw.options.rightClickSelectsWord = config.rightClickBehavior === "selectWord";
432
532
  this.raw.options.wordSeparator = config.wordSeparators;
433
533
  this.raw.options.ignoreBracketedPasteMode = config.ignoreBracketedPasteMode;
434
534
  this.raw.options.rescaleOverlappingGlyphs = config.rescaleOverlappingGlyphs;
535
+ this.raw.options.vtExtensions = {
536
+ kittyKeyboard: config.enableKittyKeyboardProtocol,
537
+ win32InputMode: config.enableWin32InputMode
538
+ };
435
539
  this._updateSmoothScrolling();
436
540
  if (this._attached) {
437
541
  if (this._attached.options.enableGpu) {
438
542
  if (this._shouldLoadWebgl()) {
439
543
  this._enableWebglRenderer();
440
- }
441
- else {
544
+ } else {
442
545
  this._disposeOfWebglRenderer();
443
546
  }
444
547
  }
@@ -449,7 +552,7 @@ let XtermTerminal = class XtermTerminal extends Disposable {
449
552
  this.raw.options.smoothScrollDuration = this._terminalConfigurationService.config.smoothScrolling && this._isPhysicalMouseWheel ? RenderConstants.SmoothScrollDuration : 0;
450
553
  }
451
554
  _shouldLoadWebgl() {
452
- return (this._terminalConfigurationService.config.gpuAcceleration === 'auto' && XtermTerminal_1._suggestedRendererType === undefined) || this._terminalConfigurationService.config.gpuAcceleration === 'on';
555
+ return (this._terminalConfigurationService.config.gpuAcceleration === "auto" && XtermTerminal_1._suggestedRendererType === undefined) || this._terminalConfigurationService.config.gpuAcceleration === "on";
453
556
  }
454
557
  forceRedraw() {
455
558
  this.raw.clearTextureAtlas();
@@ -479,22 +582,24 @@ let XtermTerminal = class XtermTerminal extends Disposable {
479
582
  const findMatchHighlightOverviewRuler = theme.getColor(TERMINAL_OVERVIEW_RULER_FIND_MATCH_FOREGROUND_COLOR);
480
583
  searchOptions.decorations = {
481
584
  activeMatchBackground: findMatchBackground?.toString(),
482
- activeMatchBorder: findMatchBorder?.toString() || 'transparent',
483
- activeMatchColorOverviewRuler: findMatchOverviewRuler?.toString() || 'transparent',
585
+ activeMatchBorder: findMatchBorder?.toString() || "transparent",
586
+ activeMatchColorOverviewRuler: findMatchOverviewRuler?.toString() || "transparent",
484
587
  matchBackground: terminalBackground ? findMatchHighlightBackground?.blend(terminalBackground).toString() : undefined,
485
- matchBorder: findMatchHighlightBorder?.toString() || 'transparent',
486
- matchOverviewRuler: findMatchHighlightOverviewRuler?.toString() || 'transparent'
588
+ matchBorder: findMatchHighlightBorder?.toString() || "transparent",
589
+ matchOverviewRuler: findMatchHighlightOverviewRuler?.toString() || "transparent"
487
590
  };
488
591
  }
489
592
  _getSearchAddon() {
490
593
  if (!this._searchAddonPromise) {
491
- this._searchAddonPromise = this._xtermAddonLoader.importAddon('search').then((AddonCtor) => {
594
+ this._searchAddonPromise = this._xtermAddonLoader.importAddon("search").then(AddonCtor => {
492
595
  if (this._store.isDisposed) {
493
- return Promise.reject('Could not create search addon, terminal is disposed');
596
+ return Promise.reject("Could not create search addon, terminal is disposed");
494
597
  }
495
- this._searchAddon = ( new AddonCtor({ highlightLimit: XtermTerminalConstants.SearchHighlightLimit }));
598
+ this._searchAddon = ( new AddonCtor({
599
+ highlightLimit: XtermTerminalConstants.SearchHighlightLimit
600
+ }));
496
601
  this.raw.loadAddon(this._searchAddon);
497
- this._searchAddon.onDidChangeResults((results) => {
602
+ this._searchAddon.onDidChangeResults(results => {
498
603
  this._lastFindResult = results;
499
604
  this._onDidChangeFindResults.fire(results);
500
605
  });
@@ -522,7 +627,10 @@ let XtermTerminal = class XtermTerminal extends Disposable {
522
627
  let maxLineLength = 0;
523
628
  for (let i = this.raw.buffer.active.length - 1; i >= this.raw.buffer.active.viewportY; i--) {
524
629
  const lineInfo = this._getWrappedLineCount(i, this.raw.buffer.active);
525
- maxLineLength = Math.max(maxLineLength, ((lineInfo.lineCount * this.raw.cols) - lineInfo.endSpaces) || 0);
630
+ maxLineLength = Math.max(
631
+ maxLineLength,
632
+ ((lineInfo.lineCount * this.raw.cols) - lineInfo.endSpaces) || 0
633
+ );
526
634
  i = lineInfo.currentIndex;
527
635
  }
528
636
  return maxLineLength;
@@ -530,15 +638,14 @@ let XtermTerminal = class XtermTerminal extends Disposable {
530
638
  _getWrappedLineCount(index, buffer) {
531
639
  let line = buffer.getLine(index);
532
640
  if (!line) {
533
- throw ( new Error('Could not get line'));
641
+ throw ( new Error("Could not get line"));
534
642
  }
535
643
  let currentIndex = index;
536
644
  let endSpaces = 0;
537
645
  for (let i = Math.min(line.length, this.raw.cols) - 1; i >= 0; i--) {
538
646
  if (!line?.getCell(i)?.getChars()) {
539
647
  endSpaces++;
540
- }
541
- else {
648
+ } else {
542
649
  break;
543
650
  }
544
651
  }
@@ -546,7 +653,11 @@ let XtermTerminal = class XtermTerminal extends Disposable {
546
653
  currentIndex--;
547
654
  line = buffer.getLine(currentIndex);
548
655
  }
549
- return { lineCount: index - currentIndex + 1, currentIndex, endSpaces };
656
+ return {
657
+ lineCount: index - currentIndex + 1,
658
+ currentIndex,
659
+ endSpaces
660
+ };
550
661
  }
551
662
  scrollDownLine() {
552
663
  this.raw.scrollLines(1);
@@ -575,6 +686,9 @@ let XtermTerminal = class XtermTerminal extends Disposable {
575
686
  this._capabilities.get(TerminalCapability.CommandDetection)?.handleCommandStart();
576
687
  this._accessibilitySignalService.playSignal(AccessibilitySignal.clear);
577
688
  }
689
+ reset() {
690
+ this.raw.reset();
691
+ }
578
692
  hasSelection() {
579
693
  return this.raw.hasSelection();
580
694
  }
@@ -609,24 +723,22 @@ let XtermTerminal = class XtermTerminal extends Disposable {
609
723
  const textAsHtml = await this.getSelectionAsHtml(command);
610
724
  function listener(e) {
611
725
  if (e.clipboardData) {
612
- if (!e.clipboardData.types.includes('text/plain')) {
613
- e.clipboardData.setData('text/plain', command?.getOutput() ?? '');
726
+ if (!e.clipboardData.types.includes("text/plain")) {
727
+ e.clipboardData.setData("text/plain", command?.getOutput() ?? "");
614
728
  }
615
- e.clipboardData.setData('text/html', textAsHtml);
729
+ e.clipboardData.setData("text/html", textAsHtml);
616
730
  }
617
731
  e.preventDefault();
618
732
  }
619
733
  const doc = getDocument(this.raw.element);
620
- doc.addEventListener('copy', listener);
621
- doc.execCommand('copy');
622
- doc.removeEventListener('copy', listener);
623
- }
624
- else {
734
+ doc.addEventListener("copy", listener);
735
+ doc.execCommand("copy");
736
+ doc.removeEventListener("copy", listener);
737
+ } else {
625
738
  await this._clipboardService.writeText(this.raw.getSelection());
626
739
  }
627
- }
628
- else {
629
- this._notificationService.warn(( localize(11703, 'The terminal has no selection to copy')));
740
+ } else {
741
+ this._notificationService.warn(( localize(12029, "The terminal has no selection to copy")));
630
742
  }
631
743
  }
632
744
  _setCursorBlink(blink) {
@@ -658,24 +770,23 @@ let XtermTerminal = class XtermTerminal extends Disposable {
658
770
  }
659
771
  this._disposeOfWebglRenderer();
660
772
  this._webglAddonCustomGlyphs = this._terminalConfigurationService.config.customGlyphs;
661
- const Addon = await this._xtermAddonLoader.importAddon('webgl');
773
+ const Addon = await this._xtermAddonLoader.importAddon("webgl");
662
774
  this._webglAddon = ( new Addon({
663
775
  customGlyphs: this._terminalConfigurationService.config.customGlyphs,
664
776
  preserveDrawingBuffer: this._terminalConfigurationService.config.preserveDrawingBuffer
665
777
  }));
666
778
  try {
667
779
  this.raw.loadAddon(this._webglAddon);
668
- this._logService.trace('Webgl was loaded');
780
+ this._logService.trace("Webgl was loaded");
669
781
  this._webglAddon.onContextLoss(() => {
670
782
  this._logService.info(`Webgl lost context, disposing of webgl renderer`);
671
783
  this._disposeOfWebglRenderer();
672
784
  });
673
785
  this._refreshImageAddon();
674
786
  this._onDidRequestRefreshDimensions.fire();
675
- }
676
- catch (e) {
787
+ } catch (e) {
677
788
  this._logService.warn(`Webgl could not be loaded. Falling back to the DOM renderer`, e);
678
- XtermTerminal_1._suggestedRendererType = 'dom';
789
+ XtermTerminal_1._suggestedRendererType = "dom";
679
790
  this._disposeOfWebglRenderer();
680
791
  }
681
792
  }
@@ -690,19 +801,18 @@ let XtermTerminal = class XtermTerminal extends Disposable {
690
801
  this._ligaturesAddon.clear();
691
802
  }
692
803
  if (!this._ligaturesAddon.value) {
693
- const LigaturesAddon = await this._xtermAddonLoader.importAddon('ligatures');
804
+ const LigaturesAddon = await this._xtermAddonLoader.importAddon("ligatures");
694
805
  if (this._store.isDisposed) {
695
806
  return;
696
807
  }
697
808
  this._ligaturesAddon.value = this._instantiationService.createInstance(LigaturesAddon, {
698
809
  fontFeatureSettings: ligaturesConfig.featureSettings,
699
- fallbackLigatures: ligaturesConfig.fallbackLigatures,
810
+ fallbackLigatures: ligaturesConfig.fallbackLigatures
700
811
  });
701
812
  this.raw.loadAddon(this._ligaturesAddon.value);
702
813
  shouldRecreateWebglRenderer = true;
703
814
  }
704
- }
705
- else {
815
+ } else {
706
816
  if (!this._ligaturesAddon.value) {
707
817
  return;
708
818
  }
@@ -717,17 +827,14 @@ let XtermTerminal = class XtermTerminal extends Disposable {
717
827
  async _refreshImageAddon() {
718
828
  if (this._terminalConfigurationService.config.enableImages && this._webglAddon) {
719
829
  if (!this._imageAddon) {
720
- const AddonCtor = await this._xtermAddonLoader.importAddon('image');
830
+ const AddonCtor = await this._xtermAddonLoader.importAddon("image");
721
831
  this._imageAddon = ( new AddonCtor());
722
832
  this.raw.loadAddon(this._imageAddon);
723
833
  }
724
- }
725
- else {
834
+ } else {
726
835
  try {
727
836
  this._imageAddon?.dispose();
728
- }
729
- catch {
730
- }
837
+ } catch {}
731
838
  this._imageAddon = undefined;
732
839
  }
733
840
  }
@@ -737,9 +844,7 @@ let XtermTerminal = class XtermTerminal extends Disposable {
737
844
  }
738
845
  try {
739
846
  this._webglAddon?.dispose();
740
- }
741
- catch {
742
- }
847
+ } catch {}
743
848
  this._webglAddon = undefined;
744
849
  this._webglAddonCustomGlyphs = undefined;
745
850
  this._refreshImageAddon();
@@ -747,19 +852,21 @@ let XtermTerminal = class XtermTerminal extends Disposable {
747
852
  }
748
853
  async getRangeAsVT(startMarker, endMarker, skipLastLine) {
749
854
  if (!this._serializeAddon) {
750
- const Addon = await this._xtermAddonLoader.importAddon('serialize');
855
+ const Addon = await this._xtermAddonLoader.importAddon("serialize");
751
856
  this._serializeAddon = ( new Addon());
752
857
  this.raw.loadAddon(this._serializeAddon);
753
858
  }
754
- assert(startMarker.line !== -1);
755
- let end = endMarker?.line ?? this.raw.buffer.active.length - 1;
756
- if (skipLastLine) {
859
+ const hasValidEndMarker = isNumber(endMarker?.line);
860
+ const start = isNumber(startMarker?.line) && startMarker?.line > -1 ? startMarker.line : 0;
861
+ let end = hasValidEndMarker ? endMarker.line : this.raw.buffer.active.length - 1;
862
+ if (skipLastLine && hasValidEndMarker) {
757
863
  end = end - 1;
758
864
  }
865
+ end = Math.max(end, start);
759
866
  return this._serializeAddon.serialize({
760
867
  range: {
761
- start: startMarker.line,
762
- end: end
868
+ start: startMarker?.line ?? 0,
869
+ end
763
870
  }
764
871
  });
765
872
  }
@@ -768,7 +875,7 @@ let XtermTerminal = class XtermTerminal extends Disposable {
768
875
  theme = this._themeService.getColorTheme();
769
876
  }
770
877
  const config = this._terminalConfigurationService.config;
771
- const hideOverviewRuler = ['never', 'gutter'].includes(config.shellIntegration?.decorationsEnabled ?? '');
878
+ const hideOverviewRuler = ["never", "gutter"].includes(config.shellIntegration?.decorationsEnabled ?? "");
772
879
  const foregroundColor = theme.getColor(TERMINAL_FOREGROUND_COLOR);
773
880
  const backgroundColor = this._xtermColorProvider.getBackgroundColor(theme);
774
881
  const cursorColor = theme.getColor(TERMINAL_CURSOR_FOREGROUND_COLOR) || foregroundColor;
@@ -784,7 +891,7 @@ let XtermTerminal = class XtermTerminal extends Disposable {
784
891
  selectionBackground: selectionBackgroundColor?.toString(),
785
892
  selectionInactiveBackground: selectionInactiveBackgroundColor?.toString(),
786
893
  selectionForeground: selectionForegroundColor?.toString(),
787
- overviewRulerBorder: hideOverviewRuler ? '#0000' : theme.getColor(TERMINAL_OVERVIEW_RULER_BORDER_COLOR)?.toString(),
894
+ overviewRulerBorder: hideOverviewRuler ? "#0000" : theme.getColor(TERMINAL_OVERVIEW_RULER_BORDER_COLOR)?.toString(),
788
895
  scrollbarSliderActiveBackground: theme.getColor(scrollbarSliderActiveBackground)?.toString(),
789
896
  scrollbarSliderBackground: theme.getColor(scrollbarSliderBackground)?.toString(),
790
897
  scrollbarSliderHoverBackground: theme.getColor(scrollbarSliderHoverBackground)?.toString(),
@@ -814,8 +921,8 @@ let XtermTerminal = class XtermTerminal extends Disposable {
814
921
  this._decorationAddon.refreshLayouts();
815
922
  }
816
923
  async _updateUnicodeVersion() {
817
- if (!this._unicode11Addon && this._terminalConfigurationService.config.unicodeVersion === '11') {
818
- const Addon = await this._xtermAddonLoader.importAddon('unicode11');
924
+ if (!this._unicode11Addon && this._terminalConfigurationService.config.unicodeVersion === "11") {
925
+ const Addon = await this._xtermAddonLoader.importAddon("unicode11");
819
926
  this._unicode11Addon = ( new Addon());
820
927
  this.raw.loadAddon(this._unicode11Addon);
821
928
  }
@@ -834,25 +941,9 @@ let XtermTerminal = class XtermTerminal extends Disposable {
834
941
  super.dispose();
835
942
  }
836
943
  };
837
- XtermTerminal.__decorator = ( __decorate([
838
- debounce(100)
839
- ], XtermTerminal.prototype, "_refreshLigaturesAddon", null));
840
- XtermTerminal.__decorator = ( __decorate([
841
- debounce(100)
842
- ], XtermTerminal.prototype, "_refreshImageAddon", null));
843
- XtermTerminal = XtermTerminal_1 = ( __decorate([
844
- ( __param(4, IConfigurationService)),
845
- ( __param(5, IInstantiationService)),
846
- ( __param(6, ITerminalLogService)),
847
- ( __param(7, INotificationService)),
848
- ( __param(8, IThemeService)),
849
- ( __param(9, ITelemetryService)),
850
- ( __param(10, ITerminalConfigurationService)),
851
- ( __param(11, IClipboardService)),
852
- ( __param(12, IContextKeyService)),
853
- ( __param(13, IAccessibilitySignalService)),
854
- ( __param(14, ILayoutService))
855
- ], XtermTerminal));
944
+ XtermTerminal.__decorator = ( __decorate([debounce(100)], XtermTerminal.prototype, "_refreshLigaturesAddon", null));
945
+ XtermTerminal.__decorator = ( __decorate([debounce(100)], XtermTerminal.prototype, "_refreshImageAddon", null));
946
+ XtermTerminal = XtermTerminal_1 = ( __decorate([( __param(4, IConfigurationService)), ( __param(5, IInstantiationService)), ( __param(6, ITerminalLogService)), ( __param(7, INotificationService)), ( __param(8, IThemeService)), ( __param(9, ITelemetryService)), ( __param(10, ITerminalConfigurationService)), ( __param(11, IClipboardService)), ( __param(12, IContextKeyService)), ( __param(13, IAccessibilitySignalService)), ( __param(14, ILayoutService))], XtermTerminal));
856
947
  function getXtermScaledDimensions(w, font, width, height) {
857
948
  if (!font.charWidth || !font.charHeight) {
858
949
  return null;
@@ -864,21 +955,30 @@ function getXtermScaledDimensions(w, font, width, height) {
864
955
  const scaledCharHeight = Math.ceil(font.charHeight * w.devicePixelRatio);
865
956
  const scaledLineHeight = Math.floor(scaledCharHeight * font.lineHeight);
866
957
  const rows = Math.max(Math.floor(scaledHeightAvailable / scaledLineHeight), 1);
867
- return { rows, cols };
958
+ return {
959
+ rows,
960
+ cols
961
+ };
868
962
  }
869
963
  function vscodeToXtermLogLevel(logLevel) {
870
964
  switch (logLevel) {
871
- case LogLevel.Trace: return 'trace';
872
- case LogLevel.Debug: return 'debug';
873
- case LogLevel.Info: return 'info';
874
- case LogLevel.Warning: return 'warn';
875
- case LogLevel.Error: return 'error';
876
- default: return 'off';
965
+ case LogLevel.Trace:
966
+ return "trace";
967
+ case LogLevel.Debug:
968
+ return "debug";
969
+ case LogLevel.Info:
970
+ return "info";
971
+ case LogLevel.Warning:
972
+ return "warn";
973
+ case LogLevel.Error:
974
+ return "error";
975
+ default:
976
+ return "off";
877
977
  }
878
978
  }
879
979
  function vscodeToXtermCursorStyle(style) {
880
- if (style === 'line') {
881
- return 'bar';
980
+ if (style === "line") {
981
+ return "bar";
882
982
  }
883
983
  return style;
884
984
  }