@@ -20,6 +20,7 @@ const SMALL_HISTOGRAM_NUM_BINS = 80;
20
20
const LARGE_HISTOGRAM_NUM_BINS = 200 ;
21
21
const SMALL_FREQUENCY_TABLE_LIMIT = 8 ;
22
22
const LARGE_FREQUENCY_TABLE_LIMIT = 16 ;
23
+ const UPDATE_EVENT_DEBOUNCE_DELAY = 50 ;
23
24
24
25
/**
25
26
* UpdateDescriptor interface.
@@ -52,6 +53,11 @@ export class TableSummaryCache extends Disposable {
52
53
*/
53
54
private _trimCacheTimeout ?: Timeout ;
54
55
56
+ /**
57
+ * Gets or sets the debounced update event timeout.
58
+ */
59
+ private _debouncedUpdateTimeout ?: Timeout ;
60
+
55
61
/**
56
62
* The search text used to filter the dataset in the column schema
57
63
* and column profile caches. The last search text value is maintained
@@ -126,6 +132,9 @@ export class TableSummaryCache extends Disposable {
126
132
// Clear the trim cache timeout.
127
133
this . clearTrimCacheTimeout ( ) ;
128
134
135
+ // Clear the debounced update timeout.
136
+ this . clearDebouncedUpdateTimeout ( ) ;
137
+
129
138
// Call the base class's dispose method.
130
139
super . dispose ( ) ;
131
140
}
@@ -465,8 +474,8 @@ export class TableSummaryCache extends Disposable {
465
474
if ( results . length > 0 ) {
466
475
this . _columnProfileCache . set ( columnIndex , results [ 0 ] ) ;
467
476
}
468
- // Fire the onDidUpdate event immediately
469
- this . _onDidUpdateEmitter . fire ( ) ;
477
+ // Fire the onDidUpdate event with debouncing for smoother updates
478
+ this . fireOnDidUpdateDebounced ( ) ;
470
479
return results ;
471
480
} )
472
481
. catch ( error => {
@@ -547,6 +556,31 @@ export class TableSummaryCache extends Disposable {
547
556
}
548
557
}
549
558
559
+ /**
560
+ * Clears the debounced update timeout.
561
+ */
562
+ private clearDebouncedUpdateTimeout ( ) {
563
+ // If there is a debounced update timeout scheduled, clear it.
564
+ if ( this . _debouncedUpdateTimeout ) {
565
+ clearTimeout ( this . _debouncedUpdateTimeout ) ;
566
+ this . _debouncedUpdateTimeout = undefined ;
567
+ }
568
+ }
569
+
570
+ /**
571
+ * Fires the onDidUpdate event with debouncing to smooth incremental updates.
572
+ */
573
+ private fireOnDidUpdateDebounced ( ) {
574
+ // Clear any existing debounced update timeout.
575
+ this . clearDebouncedUpdateTimeout ( ) ;
576
+
577
+ // Set a new debounced update timeout.
578
+ this . _debouncedUpdateTimeout = setTimeout ( ( ) => {
579
+ this . _debouncedUpdateTimeout = undefined ;
580
+ this . _onDidUpdateEmitter . fire ( ) ;
581
+ } , UPDATE_EVENT_DEBOUNCE_DELAY ) ;
582
+ }
583
+
550
584
/**
551
585
* Trims the data in the cache that is not contained between start and end column index.
552
586
* @param startColumnIndex The start column index.
0 commit comments