Skip to content

Commit 643f651

Browse files
committed
fix an issue with fs events, microsoft#13182
1 parent 1a0cce8 commit 643f651

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
1717
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
1818
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
1919
import { join, basename, extname } from 'path';
20-
import { mkdirp, readdir } from 'vs/base/node/pfs';
20+
import { mkdirp, readdir, exists } from 'vs/base/node/pfs';
2121
import { watch } from 'fs';
2222
import { SnippetFile, Snippet } from 'vs/workbench/parts/snippets/electron-browser/snippetsFile';
2323
import { ISnippetsService } from 'vs/workbench/parts/snippets/electron-browser/snippets.contribution';
@@ -218,19 +218,19 @@ class SnippetsService implements ISnippetsService {
218218
return;
219219
}
220220
const filepath = join(userSnippetsFolder, filename);
221-
if (type === 'change') {
222-
// `changed` file
223-
if (this._files.has(filepath)) {
224-
this._files.get(filepath).reset();
225-
}
226-
} else if (type === 'rename') {
227-
// `created` or `deleted` file
228-
if (!this._files.has(filepath)) {
229-
addUserSnippet(filepath);
221+
exists(filepath).then(value => {
222+
if (value) {
223+
// file created or changed
224+
if (this._files.has(filepath)) {
225+
this._files.get(filepath).reset();
226+
} else {
227+
addUserSnippet(filepath);
228+
}
230229
} else {
230+
// file not found
231231
this._files.delete(filepath);
232232
}
233-
}
233+
});
234234
});
235235
}).then(undefined, err => {
236236
this._logService.error('Failed to load user snippets', err);

0 commit comments

Comments
 (0)