@@ -10,6 +10,7 @@ import * as fs from 'original-fs';
1010import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
1111import { createDecorator } from 'vs/platform/instantiation/common/instantiation' ;
1212import { writeFileAndFlushSync } from 'vs/base/node/extfs' ;
13+ import { isUndefined , isUndefinedOrNull } from 'vs/base/common/types' ;
1314
1415export const IStorageService = createDecorator < IStorageService > ( 'storageService' ) ;
1516
@@ -33,7 +34,7 @@ export class FileStorage {
3334 }
3435
3536 const res = this . database [ key ] ;
36- if ( typeof res === 'undefined' ) {
37+ if ( isUndefinedOrNull ( res ) ) {
3738 return defaultValue ;
3839 }
3940
@@ -45,6 +46,11 @@ export class FileStorage {
4546 this . database = this . load ( ) ;
4647 }
4748
49+ // Remove an item when it is undefined or null
50+ if ( isUndefinedOrNull ( data ) ) {
51+ return this . removeItem ( key ) ;
52+ }
53+
4854 // Shortcut for primitives that did not change
4955 if ( typeof data === 'string' || typeof data === 'number' || typeof data === 'boolean' ) {
5056 if ( this . database [ key ] === data ) {
@@ -61,8 +67,9 @@ export class FileStorage {
6167 this . database = this . load ( ) ;
6268 }
6369
64- if ( this . database [ key ] ) {
65- delete this . database [ key ] ;
70+ // Only update if the key is actually present (not undefined)
71+ if ( ! isUndefined ( this . database [ key ] ) ) {
72+ this . database [ key ] = void 0 ;
6673 this . save ( ) ;
6774 }
6875 }
0 commit comments