Skip to content

Commit c65f503

Browse files
committed
Add image support setting, disabled by default
1 parent e7a3127 commit c65f503

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

src/vs/platform/terminal/common/terminal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export const enum TerminalSettingId {
117117
ShellIntegrationDecorationsEnabled = 'terminal.integrated.shellIntegration.decorationsEnabled',
118118
ShellIntegrationCommandHistory = 'terminal.integrated.shellIntegration.history',
119119
ShellIntegrationSuggestEnabled = 'terminal.integrated.shellIntegration.suggestEnabled',
120+
ExperimentalImageSupport = 'terminal.integrated.experimentalImageSupport',
120121
SmoothScrolling = 'terminal.integrated.smoothScrolling'
121122
}
122123

src/vs/workbench/contrib/terminal/browser/xterm/xtermTerminal.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
246246

247247
// Load addons
248248
this._updateUnicodeVersion();
249+
this._refreshImageAddon();
249250
this._markNavigationAddon = this._instantiationService.createInstance(MarkNavigationAddon, _capabilities);
250251
this.raw.loadAddon(this._markNavigationAddon);
251252
this._decorationAddon = this._instantiationService.createInstance(DecorationAddon, this._capabilities);
@@ -254,8 +255,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
254255
this._shellIntegrationAddon = this._instantiationService.createInstance(ShellIntegrationAddon, shellIntegrationNonce, disableShellIntegrationReporting, this._telemetryService);
255256
this.raw.loadAddon(this._shellIntegrationAddon);
256257

257-
this._getImageAddon();
258-
259258
// Load the suggest addon, this should be loaded regardless of the setting as the sequences
260259
// may still come in
261260
this._suggestAddon = this._instantiationService.createInstance(SuggestAddon, this._terminalSuggestWidgetVisibleContextKey);
@@ -337,6 +336,7 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
337336
this._disposeOfCanvasRenderer();
338337
}
339338
}
339+
this._refreshImageAddon();
340340
}
341341

342342
private _shouldLoadWebgl(): boolean {
@@ -420,19 +420,6 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
420420
return this._searchAddon;
421421
}
422422

423-
private async _getImageAddon(): Promise<ImageAddonType> {
424-
if (this._imageAddon) {
425-
return this._imageAddon;
426-
}
427-
console.log('1');
428-
const AddonCtor = await this._getImageAddonConstructor();
429-
this._imageAddon = new AddonCtor();
430-
console.log('2');
431-
this.raw.loadAddon(this._imageAddon);
432-
console.log('3');
433-
return this._imageAddon;
434-
}
435-
436423
clearSearchDecorations(): void {
437424
this._searchAddon?.clearDecorations();
438425
}
@@ -591,6 +578,23 @@ export class XtermTerminal extends DisposableStore implements IXtermTerminal, II
591578
return CanvasAddon;
592579
}
593580

581+
private async _refreshImageAddon(): Promise<void> {
582+
if (this._configHelper.config.experimentalImageSupport) {
583+
if (!this._imageAddon) {
584+
const AddonCtor = await this._getImageAddonConstructor();
585+
this._imageAddon = new AddonCtor();
586+
this.raw.loadAddon(this._imageAddon);
587+
}
588+
} else {
589+
try {
590+
this._imageAddon?.dispose();
591+
} catch {
592+
// ignore
593+
}
594+
this._imageAddon = undefined;
595+
}
596+
}
597+
594598
protected async _getImageAddonConstructor(): Promise<typeof ImageAddonType> {
595599
if (!ImageAddon) {
596600
ImageAddon = (await import('xterm-addon-image')).ImageAddon;

src/vs/workbench/contrib/terminal/common/terminal.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export interface ITerminalConfiguration {
304304
enabled: boolean;
305305
decorationsEnabled: boolean;
306306
};
307+
experimentalImageSupport: boolean;
307308
smoothScrolling: boolean;
308309
}
309310

src/vs/workbench/contrib/terminal/common/terminalConfiguration.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,14 @@ const terminalConfiguration: IConfigurationNode = {
585585
markdownDescription: localize('terminal.integrated.smoothScrolling', "Controls whether the terminal will scroll using an animation."),
586586
type: 'boolean',
587587
default: false
588-
}
588+
},
589+
[TerminalSettingId.ExperimentalImageSupport]: {
590+
restricted: true,
591+
markdownDescription: localize('terminal.integrated.experimentalImageSupport', "Enables experimental image support in the terminal. Both sixel and iTerm's inline image protocol are supported."),
592+
type: 'boolean',
593+
default: false,
594+
tags: ['experimental']
595+
},
589596
}
590597
};
591598

0 commit comments

Comments
 (0)