@@ -7,6 +7,7 @@ import { insert } from 'vs/base/common/arrays';
7
7
import { ThrottledDelayer } from 'vs/base/common/async' ;
8
8
import { onUnexpectedError } from 'vs/base/common/errors' ;
9
9
import { Emitter } from 'vs/base/common/event' ;
10
+ import { removeTrailingPathSeparator } from 'vs/base/common/extpath' ;
10
11
import { Disposable , IDisposable , toDisposable } from 'vs/base/common/lifecycle' ;
11
12
import { normalize } from 'vs/base/common/path' ;
12
13
import { URI } from 'vs/base/common/uri' ;
@@ -66,14 +67,21 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
66
67
67
68
private universalWatcher : AbstractUniversalWatcherClient | undefined ;
68
69
69
- private readonly universalPathsToWatch : IUniversalWatchRequest [ ] = [ ] ;
70
+ private readonly universalWatchRequests : IUniversalWatchRequest [ ] = [ ] ;
70
71
private readonly universalWatchRequestDelayer = this . _register ( new ThrottledDelayer < void > ( 0 ) ) ;
71
72
72
73
private watchUniversal ( resource : URI , opts : IWatchOptions ) : IDisposable {
73
74
74
75
// Add to list of paths to watch universally
75
- const pathToWatch : IUniversalWatchRequest = { path : this . toFilePath ( resource ) , excludes : opts . excludes , includes : opts . includes , recursive : opts . recursive , filter : opts . filter , correlationId : opts . correlationId } ;
76
- const remove = insert ( this . universalPathsToWatch , pathToWatch ) ;
76
+ const request : IUniversalWatchRequest = {
77
+ path : this . toWatchPath ( resource ) ,
78
+ excludes : opts . excludes ,
79
+ includes : opts . includes ,
80
+ recursive : opts . recursive ,
81
+ filter : opts . filter ,
82
+ correlationId : opts . correlationId
83
+ } ;
84
+ const remove = insert ( this . universalWatchRequests , request ) ;
77
85
78
86
// Trigger update
79
87
this . refreshUniversalWatchers ( ) ;
@@ -116,13 +124,13 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
116
124
// Adjust for polling
117
125
const usePolling = this . options ?. watcher ?. recursive ?. usePolling ;
118
126
if ( usePolling === true ) {
119
- for ( const request of this . universalPathsToWatch ) {
127
+ for ( const request of this . universalWatchRequests ) {
120
128
if ( isRecursiveWatchRequest ( request ) ) {
121
129
request . pollingInterval = this . options ?. watcher ?. recursive ?. pollingInterval ?? 5000 ;
122
130
}
123
131
}
124
132
} else if ( Array . isArray ( usePolling ) ) {
125
- for ( const request of this . universalPathsToWatch ) {
133
+ for ( const request of this . universalWatchRequests ) {
126
134
if ( isRecursiveWatchRequest ( request ) ) {
127
135
if ( usePolling . includes ( request . path ) ) {
128
136
request . pollingInterval = this . options ?. watcher ?. recursive ?. pollingInterval ?? 5000 ;
@@ -132,7 +140,7 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
132
140
}
133
141
134
142
// Ask to watch the provided paths
135
- return this . universalWatcher . watch ( this . universalPathsToWatch ) ;
143
+ return this . universalWatcher . watch ( this . universalWatchRequests ) ;
136
144
}
137
145
138
146
protected abstract createUniversalWatcher (
@@ -147,14 +155,21 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
147
155
148
156
private nonRecursiveWatcher : AbstractNonRecursiveWatcherClient | undefined ;
149
157
150
- private readonly nonRecursivePathsToWatch : INonRecursiveWatchRequest [ ] = [ ] ;
158
+ private readonly nonRecursiveWatchRequests : INonRecursiveWatchRequest [ ] = [ ] ;
151
159
private readonly nonRecursiveWatchRequestDelayer = this . _register ( new ThrottledDelayer < void > ( 0 ) ) ;
152
160
153
161
private watchNonRecursive ( resource : URI , opts : IWatchOptions ) : IDisposable {
154
162
155
163
// Add to list of paths to watch non-recursively
156
- const pathToWatch : INonRecursiveWatchRequest = { path : this . toFilePath ( resource ) , excludes : opts . excludes , includes : opts . includes , recursive : false , filter : opts . filter , correlationId : opts . correlationId } ;
157
- const remove = insert ( this . nonRecursivePathsToWatch , pathToWatch ) ;
164
+ const request : INonRecursiveWatchRequest = {
165
+ path : this . toWatchPath ( resource ) ,
166
+ excludes : opts . excludes ,
167
+ includes : opts . includes ,
168
+ recursive : false ,
169
+ filter : opts . filter ,
170
+ correlationId : opts . correlationId
171
+ } ;
172
+ const remove = insert ( this . nonRecursiveWatchRequests , request ) ;
158
173
159
174
// Trigger update
160
175
this . refreshNonRecursiveWatchers ( ) ;
@@ -195,7 +210,7 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
195
210
}
196
211
197
212
// Ask to watch the provided paths
198
- return this . nonRecursiveWatcher . watch ( this . nonRecursivePathsToWatch ) ;
213
+ return this . nonRecursiveWatcher . watch ( this . nonRecursiveWatchRequests ) ;
199
214
}
200
215
201
216
protected abstract createNonRecursiveWatcher (
@@ -221,4 +236,14 @@ export abstract class AbstractDiskFileSystemProvider extends Disposable implemen
221
236
protected toFilePath ( resource : URI ) : string {
222
237
return normalize ( resource . fsPath ) ;
223
238
}
239
+
240
+ private toWatchPath ( resource : URI ) : string {
241
+ const filePath = this . toFilePath ( resource ) ;
242
+
243
+ // Ensure to have any trailing path separators removed, otherwise
244
+ // we may believe the path is not "real" and will convert every
245
+ // event back to this form, which is not warranted.
246
+ // See also https://github.com/microsoft/vscode/issues/210517
247
+ return removeTrailingPathSeparator ( filePath ) ;
248
+ }
224
249
}
0 commit comments