@@ -30,7 +30,7 @@ import { IJSONEditingService } from 'vs/workbench/services/configuration/common/
3030import { JSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditingService' ;
3131import { createHash } from 'crypto' ;
3232import { Schemas } from 'vs/base/common/network' ;
33- import { originalFSPath } from 'vs/base/common/resources' ;
33+ import { originalFSPath , joinPath } from 'vs/base/common/resources' ;
3434import { isLinux } from 'vs/base/common/platform' ;
3535import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browser/remoteAgentServiceImpl' ;
3636import { RemoteAuthorityResolverService } from 'vs/platform/remote/electron-browser/remoteAuthorityResolverService' ;
@@ -47,6 +47,7 @@ import { IKeybindingEditingService, KeybindingsEditingService } from 'vs/workben
4747import { NativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-browser/environmentService' ;
4848import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
4949import { timeout } from 'vs/base/common/async' ;
50+ import { VSBuffer } from 'vs/base/common/buffer' ;
5051
5152class TestEnvironmentService extends NativeWorkbenchEnvironmentService {
5253
@@ -719,6 +720,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
719720
720721 let workspaceName = `testWorkspace${ uuid . generateUuid ( ) } ` , parentResource : string , workspaceDir : string , testObject : IConfigurationService , globalSettingsFile : string , globalTasksFile : string , workspaceService : WorkspaceService ;
721722 const configurationRegistry = Registry . as < IConfigurationRegistry > ( ConfigurationExtensions . Configuration ) ;
723+ let fileService : IFileService ;
722724
723725 suiteSetup ( ( ) => {
724726 configurationRegistry . registerConfiguration ( {
@@ -767,7 +769,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
767769 const environmentService = new TestEnvironmentService ( URI . file ( parentDir ) ) ;
768770 const remoteAgentService = instantiationService . createInstance ( RemoteAgentService , { } ) ;
769771 instantiationService . stub ( IRemoteAgentService , remoteAgentService ) ;
770- const fileService = new FileService ( new NullLogService ( ) ) ;
772+ fileService = new FileService ( new NullLogService ( ) ) ;
771773 const diskFileSystemProvider = new DiskFileSystemProvider ( new NullLogService ( ) ) ;
772774 fileService . registerProvider ( Schemas . file , diskFileSystemProvider ) ;
773775 fileService . registerProvider ( Schemas . userData , new FileUserDataProvider ( environmentService . appSettingsHome , environmentService . backupHome , diskFileSystemProvider , environmentService ) ) ;
@@ -776,6 +778,9 @@ suite('WorkspaceConfigurationService - Folder', () => {
776778 instantiationService . stub ( IConfigurationService , workspaceService ) ;
777779 instantiationService . stub ( IEnvironmentService , environmentService ) ;
778780
781+ // Watch workspace configuration directory
782+ fileService . watch ( joinPath ( URI . file ( workspaceDir ) , '.vscode' ) ) ;
783+
779784 return workspaceService . initialize ( convertToWorkspacePayload ( URI . file ( folderDir ) ) ) . then ( ( ) => {
780785 instantiationService . stub ( IFileService , fileService ) ;
781786 instantiationService . stub ( IKeybindingEditingService , instantiationService . createInstance ( KeybindingsEditingService ) ) ;
@@ -1101,6 +1106,37 @@ suite('WorkspaceConfigurationService - Folder', () => {
11011106 fs . writeFileSync ( globalTasksFile , '{ "version": "1.0.0", "tasks": [{ "taskName": "myTask" }' ) ;
11021107 return new Promise ( ( c ) => testObject . onDidChangeConfiguration ( ( ) => c ( ) ) ) ;
11031108 } ) ;
1109+
1110+ test ( 'creating workspace settings' , async ( ) => {
1111+ fs . writeFileSync ( globalSettingsFile , '{ "configurationService.folder.testSetting": "userValue" }' ) ;
1112+ await testObject . reloadConfiguration ( ) ;
1113+ const workspaceSettingsResource = URI . file ( path . join ( workspaceDir , '.vscode' , 'settings.json' ) ) ;
1114+ await new Promise ( async ( c ) => {
1115+ const disposable = testObject . onDidChangeConfiguration ( e => {
1116+ assert . ok ( e . affectsConfiguration ( 'configurationService.folder.testSetting' ) ) ;
1117+ assert . equal ( testObject . getValue ( 'configurationService.folder.testSetting' ) , 'workspaceValue' ) ;
1118+ disposable . dispose ( ) ;
1119+ c ( ) ;
1120+ } ) ;
1121+ await fileService . writeFile ( workspaceSettingsResource , VSBuffer . fromString ( '{ "configurationService.folder.testSetting": "workspaceValue" }' ) ) ;
1122+ } ) ;
1123+ } ) ;
1124+
1125+ test ( 'deleting workspace settings' , async ( ) => {
1126+ fs . writeFileSync ( globalSettingsFile , '{ "configurationService.folder.testSetting": "userValue" }' ) ;
1127+ const workspaceSettingsResource = URI . file ( path . join ( workspaceDir , '.vscode' , 'settings.json' ) ) ;
1128+ await fileService . writeFile ( workspaceSettingsResource , VSBuffer . fromString ( '{ "configurationService.folder.testSetting": "workspaceValue" }' ) ) ;
1129+ await testObject . reloadConfiguration ( ) ;
1130+ await new Promise ( async ( c ) => {
1131+ const disposable = testObject . onDidChangeConfiguration ( e => {
1132+ assert . ok ( e . affectsConfiguration ( 'configurationService.folder.testSetting' ) ) ;
1133+ assert . equal ( testObject . getValue ( 'configurationService.folder.testSetting' ) , 'userValue' ) ;
1134+ disposable . dispose ( ) ;
1135+ c ( ) ;
1136+ } ) ;
1137+ await fileService . del ( workspaceSettingsResource ) ;
1138+ } ) ;
1139+ } ) ;
11041140} ) ;
11051141
11061142suite ( 'WorkspaceConfigurationService-Multiroot' , ( ) => {
0 commit comments