Remove thisArg from addWatcher and use bind instead

This commit is contained in:
Robert 2024-02-07 14:51:11 +00:00
Родитель 1004f16b10
Коммит 8a389f2eb7
1 изменённых файлов: 5 добавлений и 9 удалений

Просмотреть файл

@ -18,15 +18,11 @@ class WatcherCollection extends DisposableObject {
* deleted.
* @param thisArgs The `this` argument for the event listener.
*/
public addWatcher(
pattern: GlobPattern,
listener: (e: Uri) => void,
thisArgs: any,
): void {
public addWatcher(pattern: GlobPattern, listener: (e: Uri) => void): void {
const watcher = workspace.createFileSystemWatcher(pattern);
this.push(watcher.onDidCreate(listener, thisArgs));
this.push(watcher.onDidChange(listener, thisArgs));
this.push(watcher.onDidDelete(listener, thisArgs));
this.push(watcher.onDidCreate(listener));
this.push(watcher.onDidChange(listener));
this.push(watcher.onDidDelete(listener));
}
}
@ -54,7 +50,7 @@ export class MultiFileSystemWatcher extends DisposableObject {
* @param pattern The pattern to watch.
*/
public addWatch(pattern: GlobPattern): void {
this.watchers.addWatcher(pattern, this.handleDidChange, this);
this.watchers.addWatcher(pattern, this.handleDidChange.bind(this));
}
/**