@@ -17,7 +17,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
1717import { IExtensionService } from 'vs/platform/extensions/common/extensions' ;
1818import { IDisposable , dispose } from 'vs/base/common/lifecycle' ;
1919import { join , basename , extname } from 'path' ;
20- import { mkdirp , readdir } from 'vs/base/node/pfs' ;
20+ import { mkdirp , readdir , exists } from 'vs/base/node/pfs' ;
2121import { watch } from 'fs' ;
2222import { SnippetFile , Snippet } from 'vs/workbench/parts/snippets/electron-browser/snippetsFile' ;
2323import { 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