@@ -10,7 +10,7 @@ import { DomScrollableElement } from '../scrollbar/scrollableElement.js';
1010import { commonPrefixLength } from '../../../common/arrays.js' ;
1111import { ThemeIcon } from '../../../common/themables.js' ;
1212import { Emitter , Event } from '../../../common/event.js' ;
13- import { DisposableStore , dispose , IDisposable } from '../../../common/lifecycle.js' ;
13+ import { DisposableStore , dispose , IDisposable , MutableDisposable } from '../../../common/lifecycle.js' ;
1414import { ScrollbarVisibility } from '../../../common/scrollable.js' ;
1515import './breadcrumbsWidget.css' ;
1616
@@ -60,14 +60,16 @@ export class BreadcrumbsWidget {
6060
6161 private _pendingDimLayout : IDisposable | undefined ;
6262 private _pendingLayout : IDisposable | undefined ;
63+ private readonly _pendingReveal = this . _disposables . add ( new MutableDisposable < IDisposable > ( ) ) ;
6364 private _dimension : dom . Dimension | undefined ;
6465
6566 constructor (
6667 container : HTMLElement ,
6768 horizontalScrollbarSize : number ,
6869 horizontalScrollbarVisibility : ScrollbarVisibility = ScrollbarVisibility . Auto ,
6970 separatorIcon : ThemeIcon ,
70- styles : IBreadcrumbsWidgetStyles
71+ styles : IBreadcrumbsWidgetStyles ,
72+ private readonly _measure : typeof dom . measure = dom . measure ,
7173 ) {
7274 this . _domNode = document . createElement ( 'div' ) ;
7375 this . _domNode . className = 'monaco-breadcrumbs' ;
@@ -241,18 +243,33 @@ export class BreadcrumbsWidget {
241243 }
242244
243245 private _reveal ( nth : number , minimal : boolean ) : void {
246+ this . _pendingReveal . clear ( ) ;
244247 if ( nth < 0 || nth >= this . _nodes . length ) {
245248 return ;
246249 }
247250 const node = this . _nodes [ nth ] ;
248251 if ( ! node ) {
249252 return ;
250253 }
254+ if ( ! minimal ) {
255+ this . _pendingReveal . value = this . _measure ( dom . getWindow ( this . _domNode ) , ( ) => {
256+ if ( this . _nodes [ nth ] === node ) {
257+ this . _revealNode ( node , false ) ;
258+ }
259+ } ) ;
260+ return ;
261+ }
262+
263+ this . _revealNode ( node , true ) ;
264+ }
265+
266+ private _revealNode ( node : HTMLElement , minimal : boolean ) : void {
251267 const { width } = this . _scrollable . getScrollDimensions ( ) ;
252268 const { scrollLeft } = this . _scrollable . getScrollPosition ( ) ;
253- if ( ! minimal || node . offsetLeft > scrollLeft + width || node . offsetLeft < scrollLeft ) {
269+ const nodeOffsetLeft = node . offsetLeft ;
270+ if ( ! minimal || nodeOffsetLeft > scrollLeft + width || nodeOffsetLeft < scrollLeft ) {
254271 this . _scrollable . setRevealOnScroll ( false ) ;
255- this . _scrollable . setScrollPosition ( { scrollLeft : node . offsetLeft } ) ;
272+ this . _scrollable . setScrollPosition ( { scrollLeft : nodeOffsetLeft } ) ;
256273 this . _scrollable . setRevealOnScroll ( true ) ;
257274 }
258275 }
0 commit comments