@@ -59,6 +59,7 @@ export class TerminalStickyScrollOverlay extends Disposable {
59
59
private _refreshListeners = this . _register ( new MutableDisposable ( ) ) ;
60
60
61
61
private _state : OverlayState = OverlayState . Off ;
62
+ private _isRefreshQueued = false ;
62
63
private _rawMaxLineCount : number = 5 ;
63
64
64
65
constructor (
@@ -114,7 +115,7 @@ export class TerminalStickyScrollOverlay extends Disposable {
114
115
} ) ) ;
115
116
this . _register ( this . _xterm . raw . onResize ( ( ) => {
116
117
this . _syncOptions ( ) ;
117
- this . _throttledRefresh ( ) ;
118
+ this . _refresh ( ) ;
118
119
} ) ) ;
119
120
120
121
this . _getSerializeAddonConstructor ( ) . then ( SerializeAddon => {
@@ -175,37 +176,15 @@ export class TerminalStickyScrollOverlay extends Disposable {
175
176
this . _element ?. classList . toggle ( CssClasses . Visible , isVisible ) ;
176
177
}
177
178
178
- /**
179
- * The entry point to refresh sticky scroll. This is synchronous and will call into the method
180
- * that actually refreshes using either debouncing or throttling depending on the situation.
181
- *
182
- * The goal is that if the command has changed to update immediately (with throttling) and if
183
- * the command is the same then update with debouncing as it's less likely updates will show up.
184
- * This approach also helps with:
185
- *
186
- * - Cursor move only updates such as moving horizontally in pagers which without this may show
187
- * the sticky scroll before hiding it again almost immediately due to everything not being
188
- * parsed yet.
189
- * - Improving performance due to deferring less important updates via debouncing.
190
- * - Less flickering when scrolling, while still updating immediately when the command changes.
191
- */
192
179
private _refresh ( ) : void {
193
- if ( ! this . _xterm . raw . element ?. parentElement || ! this . _stickyScrollOverlay || ! this . _serializeAddon ) {
180
+ if ( this . _isRefreshQueued ) {
194
181
return ;
195
182
}
196
- const command = this . _commandDetection . getCommandForLine ( this . _xterm . raw . buffer . active . viewportY ) ;
197
- if ( command && this . _currentStickyCommand !== command ) {
198
- this . _throttledRefresh ( ) ;
199
- } else {
200
- // If it's the same command, do not throttle as the sticky scroll overlay height may
201
- // need to be adjusted. This would cause a flicker if throttled.
183
+ this . _isRefreshQueued = true ;
184
+ queueMicrotask ( ( ) => {
202
185
this . _refreshNow ( ) ;
203
- }
204
- }
205
-
206
- @throttle ( 0 )
207
- private _throttledRefresh ( ) : void {
208
- this . _refreshNow ( ) ;
186
+ this . _isRefreshQueued = false ;
187
+ } ) ;
209
188
}
210
189
211
190
private _refreshNow ( ) : void {
0 commit comments