@@ -72,7 +72,8 @@ export class State {
72
72
* glob: string,
73
73
* integration: import("./integrations/base.js").BaseIntegration,
74
74
* debounceDelay: number,
75
- * existingTimeout?: NodeJS.Timeout
75
+ * existingTimeout?: NodeJS.Timeout,
76
+ * accumulatedPaths?: string[],
76
77
* }[] }
77
78
*/
78
79
this . fileChangeRegister = [ ] ;
@@ -315,7 +316,7 @@ export class State {
315
316
* glob, added to {@link State#fileChangeRegister}, and call with the specified
316
317
* debounce-delay.
317
318
*
318
- * @param paths
319
+ * @param { string[] } paths
319
320
*/
320
321
emitFileChange ( paths ) {
321
322
debugPrint ( `State#emitFileChange :: ${ JSON . stringify ( paths ) } }` ) ;
@@ -326,13 +327,21 @@ export class State {
326
327
`State#emitFileChange :: Matched ${ registerItem . glob } for ${ registerItem . integration . name } debouncing with ${ registerItem . debounceDelay } .` ,
327
328
) ;
328
329
330
+ // Merge all paths from debounced matches
331
+ registerItem . accumulatedPaths ??= [ ] ;
332
+ registerItem . accumulatedPaths . push ( ...paths ) ;
333
+
329
334
if ( registerItem . existingTimeout ) {
330
335
registerItem . existingTimeout . refresh ( ) ;
331
336
} else {
332
337
registerItem . existingTimeout = setTimeout ( ( ) => {
338
+ // Reset paths for debounced matches
339
+ const accumulatedPaths = registerItem . accumulatedPaths ?? [ ] ;
340
+ registerItem . accumulatedPaths = [ ] ;
341
+
333
342
registerItem . integration . state . runTask (
334
343
"Integration#onFileChaged" ,
335
- registerItem . integration . onFileChanged ( paths ) ,
344
+ registerItem . integration . onFileChanged ( accumulatedPaths ) ,
336
345
) ;
337
346
} , registerItem . debounceDelay ) ;
338
347
}
0 commit comments