@@ -498,10 +498,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
498498 this . _container . appendChild ( this . _wrapperElement ) ;
499499 xterm . open ( this . _xtermElement ) ;
500500 if ( this . _configHelper . config . rendererType === 'experimentalWebgl' ) {
501- this . _terminalInstanceService . getXtermWebglConstructor ( ) . then ( Addon => {
502- this . _webglAddon = new Addon ( ) ;
503- xterm . loadAddon ( this . _webglAddon ) ;
504- } ) ;
501+ this . _enableWebglRenderer ( ) ;
505502 }
506503
507504 if ( ! xterm . element || ! xterm . textarea ) {
@@ -771,7 +768,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
771768 return ;
772769 }
773770 this . _webglAddon ?. clearTextureAtlas ( ) ;
774- // TODO: Do other renderers ?
771+ // TODO: Do canvas renderer too ?
775772 }
776773
777774 public focus ( force ?: boolean ) : void {
@@ -1231,15 +1228,26 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
12311228 this . _safeSetOption ( 'macOptionClickForcesSelection' , config . macOptionClickForcesSelection ) ;
12321229 this . _safeSetOption ( 'rightClickSelectsWord' , config . rightClickBehavior === 'selectWord' ) ;
12331230 this . _safeSetOption ( 'wordSeparator' , config . wordSeparators ) ;
1234- if ( config . rendererType !== 'experimentalWebgl' ) {
1235- // TODO: Unset/dispose this._webglAddon
1236-
1231+ if ( config . rendererType === 'experimentalWebgl' ) {
1232+ this . _enableWebglRenderer ( ) ;
1233+ } else {
1234+ this . _webglAddon ?. dispose ( ) ;
1235+ this . _webglAddon = undefined ;
12371236 // Never set webgl as it's an addon not a rendererType
12381237 this . _safeSetOption ( 'rendererType' , config . rendererType === 'auto' ? 'canvas' : config . rendererType ) ;
12391238 }
12401239 this . _refreshEnvironmentVariableInfoWidgetState ( this . _processManager . environmentVariableInfo ) ;
12411240 }
12421241
1242+ private async _enableWebglRenderer ( ) : Promise < void > {
1243+ if ( ! this . _xterm || this . _webglAddon ) {
1244+ return ;
1245+ }
1246+ const Addon = await this . _terminalInstanceService . getXtermWebglConstructor ( ) ;
1247+ this . _webglAddon = new Addon ( ) ;
1248+ this . _xterm . loadAddon ( this . _webglAddon ) ;
1249+ }
1250+
12431251 private async _updateUnicodeVersion ( ) : Promise < void > {
12441252 if ( ! this . _xterm ) {
12451253 throw new Error ( 'Cannot update unicode version before xterm has been initialized' ) ;
0 commit comments