@@ -116,12 +116,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
116116
117117 this . _refreshCharAtlas ( ) ;
118118
119- this . _rectangleRenderer . updateSelection ( this . _model . selection ) ;
120- this . _glyphRenderer . updateSelection ( this . _model ) ;
121-
122119 // Force a full refresh
123120 this . _model . clear ( ) ;
124- this . _model . clearSelection ( ) ;
125121 }
126122
127123 public onDevicePixelRatioChange ( ) : void {
@@ -138,7 +134,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
138134 this . _updateDimensions ( ) ;
139135
140136 this . _model . resize ( this . _terminal . cols , this . _terminal . rows ) ;
141- this . _rectangleRenderer . onResize ( ) ;
142137
143138 // Resize all render layers
144139 this . _renderLayers . forEach ( l => l . resize ( this . _terminal , this . dimensions ) ) ;
@@ -152,14 +147,20 @@ export class WebglRenderer extends Disposable implements IRenderer {
152147 // Resize the screen
153148 this . _core . screenElement ! . style . width = `${ this . dimensions . canvasWidth } px` ;
154149 this . _core . screenElement ! . style . height = `${ this . dimensions . canvasHeight } px` ;
150+
151+ this . _rectangleRenderer . onResize ( ) ;
152+ if ( this . _model . selection . hasSelection ) {
153+ // Update selection as dimensions have changed
154+ this . _rectangleRenderer . updateSelection ( this . _model . selection ) ;
155+ }
156+
155157 this . _glyphRenderer . setDimensions ( this . dimensions ) ;
156158 this . _glyphRenderer . onResize ( ) ;
157159
158160 this . _refreshCharAtlas ( ) ;
159161
160162 // Force a full refresh
161163 this . _model . clear ( ) ;
162- this . _model . clearSelection ( ) ;
163164 }
164165
165166 public onCharSizeChanged ( ) : void {
@@ -179,9 +180,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
179180
180181 this . _updateSelectionModel ( start , end , columnSelectMode ) ;
181182
182- this . _rectangleRenderer . updateSelection ( this . _model . selection ) ;
183- this . _glyphRenderer . updateSelection ( this . _model ) ;
184-
185183 this . _onRequestRedraw . fire ( { start : 0 , end : this . _terminal . rows - 1 } ) ;
186184 }
187185
@@ -220,7 +218,6 @@ export class WebglRenderer extends Disposable implements IRenderer {
220218 this . _charAtlas ?. clearTexture ( ) ;
221219 this . _model . clear ( ) ;
222220 this . _updateModel ( 0 , this . _terminal . rows - 1 ) ;
223- this . _glyphRenderer . updateSelection ( this . _model ) ;
224221 this . _onRequestRedraw . fire ( { start : 0 , end : this . _terminal . rows - 1 } ) ;
225222 }
226223
@@ -253,7 +250,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
253250 // Tell renderer the frame is beginning
254251 if ( this . _glyphRenderer . beginFrame ( ) ) {
255252 this . _model . clear ( ) ;
256- this . _model . clearSelection ( ) ;
253+ this . _updateSelectionModel ( undefined , undefined ) ;
257254 }
258255
259256 // Update model to reflect what's drawn
@@ -303,14 +300,19 @@ export class WebglRenderer extends Disposable implements IRenderer {
303300 }
304301 }
305302 this . _rectangleRenderer . updateBackgrounds ( this . _model ) ;
303+ if ( this . _model . selection . hasSelection ) {
304+ // Model could be updated but the selection is unchanged
305+ this . _glyphRenderer . updateSelection ( this . _model ) ;
306+ }
306307 }
307308
308- private _updateSelectionModel ( start : [ number , number ] | undefined , end : [ number , number ] | undefined , columnSelectMode : boolean ) : void {
309+ private _updateSelectionModel ( start : [ number , number ] | undefined , end : [ number , number ] | undefined , columnSelectMode : boolean = false ) : void {
309310 const terminal = this . _terminal ;
310311
311312 // Selection does not exist
312313 if ( ! start || ! end || ( start [ 0 ] === end [ 0 ] && start [ 1 ] === end [ 1 ] ) ) {
313314 this . _model . clearSelection ( ) ;
315+ this . _rectangleRenderer . updateSelection ( this . _model . selection ) ;
314316 return ;
315317 }
316318
@@ -323,6 +325,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
323325 // No need to draw the selection
324326 if ( viewportCappedStartRow >= terminal . rows || viewportCappedEndRow < 0 ) {
325327 this . _model . clearSelection ( ) ;
328+ this . _rectangleRenderer . updateSelection ( this . _model . selection ) ;
326329 return ;
327330 }
328331
@@ -334,6 +337,8 @@ export class WebglRenderer extends Disposable implements IRenderer {
334337 this . _model . selection . viewportCappedEndRow = viewportCappedEndRow ;
335338 this . _model . selection . startCol = start [ 0 ] ;
336339 this . _model . selection . endCol = end [ 0 ] ;
340+
341+ this . _rectangleRenderer . updateSelection ( this . _model . selection ) ;
337342 }
338343
339344 /**
0 commit comments