@@ -74,6 +74,12 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
7474 private _terminalTabsSingleSelectedContextKey : IContextKey < boolean > ;
7575 private _isSplitContextKey : IContextKey < boolean > ;
7676
77+ private _hasText : boolean = true ;
78+ get hasText ( ) : boolean { return this . _hasText ; }
79+
80+ private _hasActionBar : boolean = true ;
81+ get hasActionBar ( ) : boolean { return this . _hasActionBar ; }
82+
7783 constructor (
7884 container : HTMLElement ,
7985 @IContextKeyService contextKeyService : IContextKeyService ,
@@ -94,7 +100,7 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
94100 getHeight : ( ) => TerminalTabsListSizes . TabHeight ,
95101 getTemplateId : ( ) => 'terminal.tabs'
96102 } ,
97- [ instantiationService . createInstance ( TerminalTabsRenderer , container , instantiationService . createInstance ( ResourceLabels , DEFAULT_LABELS_CONTAINER ) , ( ) => this . getSelectedElements ( ) ) ] ,
103+ [ instantiationService . createInstance ( TerminalTabsRenderer , container , instantiationService . createInstance ( ResourceLabels , DEFAULT_LABELS_CONTAINER ) , ( ) => this . getSelectedElements ( ) , ( ) => this . hasText , ( ) => this . hasActionBar ) ] ,
98104 {
99105 horizontalScrolling : false ,
100106 supportDynamicHeights : false ,
@@ -248,15 +254,29 @@ export class TerminalTabList extends WorkbenchList<ITerminalInstance> {
248254 const instance = this . getFocusedElements ( ) ;
249255 this . _isSplitContextKey . set ( instance . length > 0 && this . _terminalGroupService . instanceIsSplit ( instance [ 0 ] ) ) ;
250256 }
257+
258+ override layout ( height ?: number , width ?: number ) : void {
259+ super . layout ( height , width ) ;
260+ const actualWidth = width ?? this . getHTMLElement ( ) . clientWidth ;
261+ const newHasText = actualWidth >= TerminalTabsListSizes . MidpointViewWidth ;
262+ const newHasActionBar = actualWidth > TerminalTabsListSizes . ActionbarMinimumWidth ;
263+ if ( this . _hasText !== newHasText || this . _hasActionBar !== newHasActionBar ) {
264+ this . _hasText = newHasText ;
265+ this . _hasActionBar = newHasActionBar ;
266+ this . refresh ( ) ;
267+ }
268+ }
251269}
252270
253271class TerminalTabsRenderer implements IListRenderer < ITerminalInstance , ITerminalTabEntryTemplate > {
254272 templateId = 'terminal.tabs' ;
255273
256274 constructor (
257- private readonly _container : HTMLElement ,
275+ _container : HTMLElement ,
258276 private readonly _labels : ResourceLabels ,
259277 private readonly _getSelection : ( ) => ITerminalInstance [ ] ,
278+ private readonly _getHasText : ( ) => boolean ,
279+ private readonly _getHasActionBar : ( ) => boolean ,
260280 @IInstantiationService private readonly _instantiationService : IInstantiationService ,
261281 @ITerminalConfigurationService private readonly _terminalConfigurationService : ITerminalConfigurationService ,
262282 @ITerminalService private readonly _terminalService : ITerminalService ,
@@ -321,25 +341,9 @@ class TerminalTabsRenderer implements IListRenderer<ITerminalInstance, ITerminal
321341 } ;
322342 }
323343
324- shouldHideText ( ) : boolean {
325- return this . _container ? this . getContainerWidthCachedForTask ( ) < TerminalTabsListSizes . MidpointViewWidth : false ;
326- }
327-
328- shouldHideActionBar ( ) : boolean {
329- return this . _container ? this . getContainerWidthCachedForTask ( ) <= TerminalTabsListSizes . ActionbarMinimumWidth : false ;
330- }
331-
332- private _cachedContainerWidth = - 1 ;
333- getContainerWidthCachedForTask ( ) : number {
334- if ( this . _cachedContainerWidth === - 1 ) {
335- this . _cachedContainerWidth = this . _container . clientWidth ;
336- queueMicrotask ( ( ) => this . _cachedContainerWidth = - 1 ) ;
337- }
338- return this . _cachedContainerWidth ;
339- }
340-
341344 renderElement ( instance : ITerminalInstance , index : number , template : ITerminalTabEntryTemplate ) : void {
342- const hasText = ! this . shouldHideText ( ) ;
345+ const hasText = this . _getHasText ( ) ;
346+ const hasActionBar = this . _getHasActionBar ( ) ;
343347
344348 const group = this . _terminalGroupService . getGroupForInstance ( instance ) ;
345349 if ( ! group ) {
@@ -365,7 +369,6 @@ class TerminalTabsRenderer implements IListRenderer<ITerminalInstance, ITerminal
365369 template . context . hoverActions = hoverInfo . actions ;
366370
367371 const iconId = this . _instantiationService . invokeFunction ( getIconId , instance ) ;
368- const hasActionbar = ! this . shouldHideActionBar ( ) ;
369372 let label : string = '' ;
370373 if ( ! hasText ) {
371374 const primaryStatus = instance . statusList . primary ;
@@ -385,7 +388,7 @@ class TerminalTabsRenderer implements IListRenderer<ITerminalInstance, ITerminal
385388 }
386389 }
387390
388- if ( ! hasActionbar ) {
391+ if ( ! hasActionBar ) {
389392 template . actionBar . clear ( ) ;
390393 }
391394
0 commit comments