@@ -24,7 +24,7 @@ import { FileWatcher as NodeJSWatcherService } from 'vs/platform/files/node/watc
24
24
import { FileWatcher as NsfwWatcherService } from 'vs/platform/files/node/watcher/nsfw/watcherService' ;
25
25
import { FileWatcher as ParcelWatcherService } from 'vs/platform/files/node/watcher/parcel/watcherService' ;
26
26
import { FileWatcher as UnixWatcherService } from 'vs/platform/files/node/watcher/unix/watcherService' ;
27
- import { IDiskFileChange , ILogMessage , WatcherService } from 'vs/platform/files/common/watcher' ;
27
+ import { IDiskFileChange , ILogMessage , IWatchRequest , WatcherService } from 'vs/platform/files/common/watcher' ;
28
28
import { ILogService } from 'vs/platform/log/common/log' ;
29
29
import product from 'vs/platform/product/common/product' ;
30
30
import { AbstractDiskFileSystemProvider } from 'vs/platform/files/common/diskFileSystemProvider' ;
@@ -43,8 +43,24 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
43
43
} ) ( ) ;
44
44
45
45
export interface IWatcherOptions {
46
- pollingInterval ?: number ;
46
+
47
+ /**
48
+ * If `true`, will enable polling for all watchers, otherwise
49
+ * will enable it for paths included in the string array.
50
+ *
51
+ * @deprecated TODO@bpasero TODO@aeschli remove me once WSL1
52
+ * support ends.
53
+ */
47
54
usePolling : boolean | string [ ] ;
55
+
56
+ /**
57
+ * If polling is enabled (via `usePolling`), defines the duration
58
+ * in which the watcher will poll for changes.
59
+ *
60
+ * @deprecated TODO@bpasero TODO@aeschli remove me once WSL1
61
+ * support ends.
62
+ */
63
+ pollingInterval ?: number ;
48
64
}
49
65
50
66
export interface IDiskFileSystemProviderOptions {
@@ -552,17 +568,10 @@ export class DiskFileSystemProvider extends AbstractDiskFileSystemProvider imple
552
568
) : WatcherService
553
569
} ;
554
570
555
- let watcherOptions : IWatcherOptions | undefined = undefined ;
556
-
557
- // requires a polling watcher
571
+ let enableLegacyWatcher = false ;
558
572
if ( this . options ?. watcher ?. usePolling ) {
559
- watcherImpl = UnixWatcherService ;
560
- watcherOptions = this . options ?. watcher ;
561
- }
562
-
563
- // can use efficient watcher
564
- else {
565
- let enableLegacyWatcher = false ;
573
+ enableLegacyWatcher = false ; // can use Parcel watcher for when polling is required
574
+ } else {
566
575
if ( this . options ?. legacyWatcher === 'on' || this . options ?. legacyWatcher === 'off' ) {
567
576
enableLegacyWatcher = this . options . legacyWatcher === 'on' ; // setting always wins
568
577
} else {
@@ -572,26 +581,43 @@ export class DiskFileSystemProvider extends AbstractDiskFileSystemProvider imple
572
581
enableLegacyWatcher = folders === 1 ;
573
582
}
574
583
}
584
+ }
575
585
576
- if ( enableLegacyWatcher ) {
577
- if ( isLinux ) {
578
- watcherImpl = UnixWatcherService ;
579
- } else {
580
- watcherImpl = NsfwWatcherService ;
581
- }
586
+ if ( enableLegacyWatcher ) {
587
+ if ( isLinux ) {
588
+ watcherImpl = UnixWatcherService ;
582
589
} else {
583
- watcherImpl = ParcelWatcherService ;
590
+ watcherImpl = NsfwWatcherService ;
584
591
}
592
+ } else {
593
+ watcherImpl = ParcelWatcherService ;
585
594
}
586
595
587
596
return new watcherImpl (
588
597
changes => onChange ( changes ) ,
589
598
msg => onLogMessage ( msg ) ,
590
599
verboseLogging ,
591
- watcherOptions
600
+ this . options ?. watcher
592
601
) ;
593
602
}
594
603
604
+ protected override doWatch ( watcher : WatcherService , requests : IWatchRequest [ ] ) : Promise < void > {
605
+ const usePolling = this . options ?. watcher ?. usePolling ;
606
+ if ( usePolling === true ) {
607
+ for ( const request of requests ) {
608
+ request . pollingInterval = this . options ?. watcher ?. pollingInterval ?? 5000 ;
609
+ }
610
+ } else if ( Array . isArray ( usePolling ) ) {
611
+ for ( const request of requests ) {
612
+ if ( usePolling . includes ( request . path ) ) {
613
+ request . pollingInterval = this . options ?. watcher ?. pollingInterval ?? 5000 ;
614
+ }
615
+ }
616
+ }
617
+
618
+ return super . doWatch ( watcher , requests ) ;
619
+ }
620
+
595
621
protected createNonRecursiveWatcher (
596
622
path : string ,
597
623
onChange : ( changes : IDiskFileChange [ ] ) => void ,
0 commit comments