@@ -8,7 +8,7 @@ import { URI, UriComponents } from 'vs/base/common/uri';
88import { ExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace' ;
99import { ExtHostConfigProvider } from 'vs/workbench/api/common/extHostConfiguration' ;
1010import { MainThreadConfigurationShape , IConfigurationInitData } from 'vs/workbench/api/common/extHost.protocol' ;
11- import { ConfigurationModel } from 'vs/platform/configuration/common/configurationModels' ;
11+ import { ConfigurationModel , ConfigurationModelParser } from 'vs/platform/configuration/common/configurationModels' ;
1212import { TestRPCProtocol } from './testRPCProtocol' ;
1313import { mock } from 'vs/workbench/test/electron-browser/api/mock' ;
1414import { IWorkspaceFolder , WorkspaceFolder } from 'vs/platform/workspace/common/workspace' ;
@@ -476,6 +476,76 @@ suite('ExtHostConfiguration', function () {
476476 assert . equal ( actual2 . workspaceFolderValue , undefined ) ;
477477 } ) ;
478478
479+ test ( 'inspect with language overrides' , function ( ) {
480+ const firstRoot = URI . file ( 'foo1' ) ;
481+ const secondRoot = URI . file ( 'foo2' ) ;
482+ const folders : [ UriComponents , IConfigurationModel ] [ ] = [ ] ;
483+ folders . push ( [ firstRoot , toConfigurationModel ( {
484+ 'editor.wordWrap' : 'bounded' ,
485+ '[typescript]' : {
486+ 'editor.wordWrap' : 'unbounded' ,
487+ }
488+ } ) ] ) ;
489+ folders . push ( [ secondRoot , toConfigurationModel ( { } ) ] ) ;
490+
491+ const extHostWorkspace = createExtHostWorkspace ( ) ;
492+ extHostWorkspace . $initializeWorkspace ( {
493+ 'id' : 'foo' ,
494+ 'folders' : [ aWorkspaceFolder ( firstRoot , 0 ) , aWorkspaceFolder ( secondRoot , 1 ) ] ,
495+ 'name' : 'foo'
496+ } ) ;
497+ const testObject = new ExtHostConfigProvider (
498+ new class extends mock < MainThreadConfigurationShape > ( ) { } ,
499+ extHostWorkspace ,
500+ {
501+ defaults : toConfigurationModel ( {
502+ 'editor.wordWrap' : 'off' ,
503+ '[markdown]' : {
504+ 'editor.wordWrap' : 'bounded' ,
505+ }
506+ } ) ,
507+ user : toConfigurationModel ( {
508+ 'editor.wordWrap' : 'bounded' ,
509+ '[typescript]' : {
510+ 'editor.lineNumbers' : 'off' ,
511+ }
512+ } ) ,
513+ workspace : toConfigurationModel ( {
514+ '[typescript]' : {
515+ 'editor.wordWrap' : 'unbounded' ,
516+ 'editor.lineNumbers' : 'off' ,
517+ }
518+ } ) ,
519+ folders,
520+ configurationScopes : [ ]
521+ } ,
522+ new NullLogService ( )
523+ ) ;
524+
525+ let actual = testObject . getConfiguration ( undefined , { uri : firstRoot , languageId : 'typescript' } ) . inspect ( 'editor.wordWrap' ) ! ;
526+ assert . equal ( actual . defaultValue , 'off' ) ;
527+ assert . equal ( actual . globalValue , 'bounded' ) ;
528+ assert . equal ( actual . workspaceValue , undefined ) ;
529+ assert . equal ( actual . workspaceFolderValue , 'bounded' ) ;
530+ assert . equal ( actual . defaultLanguageValue , undefined ) ;
531+ assert . equal ( actual . globalLanguageValue , undefined ) ;
532+ assert . equal ( actual . workspaceLanguageValue , 'unbounded' ) ;
533+ assert . equal ( actual . workspaceFolderLanguageValue , 'unbounded' ) ;
534+ assert . deepEqual ( actual . languageIds , [ 'markdown' , 'typescript' ] ) ;
535+
536+ actual = testObject . getConfiguration ( undefined , { uri : secondRoot , languageId : 'typescript' } ) . inspect ( 'editor.wordWrap' ) ! ;
537+ assert . equal ( actual . defaultValue , 'off' ) ;
538+ assert . equal ( actual . globalValue , 'bounded' ) ;
539+ assert . equal ( actual . workspaceValue , undefined ) ;
540+ assert . equal ( actual . workspaceFolderValue , undefined ) ;
541+ assert . equal ( actual . defaultLanguageValue , undefined ) ;
542+ assert . equal ( actual . globalLanguageValue , undefined ) ;
543+ assert . equal ( actual . workspaceLanguageValue , 'unbounded' ) ;
544+ assert . equal ( actual . workspaceFolderLanguageValue , undefined ) ;
545+ assert . deepEqual ( actual . languageIds , [ 'markdown' , 'typescript' ] ) ;
546+ } ) ;
547+
548+
479549 test ( 'getConfiguration vs get' , function ( ) {
480550
481551 const all = createExtHostConfiguration ( {
@@ -654,4 +724,11 @@ suite('ExtHostConfiguration', function () {
654724 function aWorkspaceFolder ( uri : URI , index : number , name : string = '' ) : IWorkspaceFolder {
655725 return new WorkspaceFolder ( { uri, name, index } ) ;
656726 }
727+
728+ function toConfigurationModel ( obj : any ) : ConfigurationModel {
729+ const parser = new ConfigurationModelParser ( 'test' ) ;
730+ parser . parseContent ( JSON . stringify ( obj ) ) ;
731+ return parser . configurationModel ;
732+ }
733+
657734} ) ;
0 commit comments