@@ -36,6 +36,8 @@ import { KeyCode } from '../../../../base/common/keyCodes.js';
36
36
import { Gesture , EventType as TouchEventType } from '../../../../base/browser/touch.js' ;
37
37
import { IEditorService } from '../../../services/editor/common/editorService.js' ;
38
38
import { IProductService } from '../../../../platform/product/common/productService.js' ;
39
+ import { isObject } from '../../../../base/common/types.js' ;
40
+ import { ILanguageService } from '../../../../editor/common/languages/language.js' ;
39
41
40
42
//#region --- colors
41
43
@@ -109,7 +111,8 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
109
111
@ICommandService private readonly commandService : ICommandService ,
110
112
@IHoverService private readonly hoverService : IHoverService ,
111
113
@IEditorService private readonly editorService : IEditorService ,
112
- @IProductService private readonly productService : IProductService
114
+ @IProductService private readonly productService : IProductService ,
115
+ @ILanguageService private readonly languageService : ILanguageService
113
116
) {
114
117
super ( ) ;
115
118
@@ -370,27 +373,42 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
370
373
}
371
374
372
375
private createSettings ( container : HTMLElement , disposables : DisposableStore ) : HTMLElement {
373
- const languageId = this . editorService . activeTextEditorLanguageId ;
376
+ const language = this . editorService . activeTextEditorLanguageId ;
374
377
const settings = container . appendChild ( $ ( 'div.settings' ) ) ;
375
378
376
379
// --- Code Completions
377
380
{
378
- const settingId = 'github.copilot.editor.enableAutoCompletions' ;
379
381
const globalSetting = append ( settings , $ ( 'div.setting' ) ) ;
380
- this . createSetting ( globalSetting , localize ( 'settings.codeCompletions' , "Code completions (all)" ) , { key : settingId , override : undefined } , disposables ) ;
382
+ this . createCodeCompletionsSetting ( globalSetting , localize ( 'settings.codeCompletions' , "Code completions (all files )" ) , '*' , disposables ) ;
381
383
382
- if ( languageId ) {
384
+ if ( language ) {
383
385
const languageSetting = append ( settings , $ ( 'div.setting' ) ) ;
384
- this . createSetting ( languageSetting , localize ( 'settings.codeCompletionsLanguage' , "Code completions ({0})" , languageId ) , { key : settingId , override : languageId } , disposables ) ;
386
+ this . createCodeCompletionsSetting ( languageSetting , localize ( 'settings.codeCompletionsLanguage' , "Code completions ({0})" , this . languageService . getLanguageName ( language ) ?? language ) , language , disposables ) ;
385
387
}
386
388
}
387
389
388
390
return settings ;
389
391
}
390
392
391
- private createSetting ( container : HTMLElement , label : string , setting : { key : string ; override : string | undefined } , disposables : DisposableStore ) : void {
392
- const readSetting = ( ) => Boolean ( this . configurationService . getValue < boolean > ( setting . key , { overrideIdentifier : setting . override } ) ) ;
393
- const writeSetting = ( checkbox : Checkbox ) => this . configurationService . updateValue ( setting . key , checkbox . checked , { overrideIdentifier : setting . override } ) ;
393
+ private createCodeCompletionsSetting ( container : HTMLElement , label : string , language : string , disposables : DisposableStore ) : void {
394
+ const settingId = 'github.copilot.enable' ;
395
+
396
+ const readSetting = ( ) => {
397
+ const result = this . configurationService . getValue < Record < string , boolean > > ( settingId ) ;
398
+ if ( ! isObject ( result ) ) {
399
+ return false ;
400
+ }
401
+
402
+ return Boolean ( result [ language ] ) ;
403
+ } ;
404
+ const writeSetting = ( checkbox : Checkbox ) => {
405
+ let result = this . configurationService . getValue < Record < string , boolean > > ( settingId ) ;
406
+ if ( ! isObject ( result ) ) {
407
+ result = Object . create ( null ) ;
408
+ }
409
+
410
+ return this . configurationService . updateValue ( settingId , { ...result , [ language ] : checkbox . checked } ) ;
411
+ } ;
394
412
395
413
const settingCheckbox = disposables . add ( new Checkbox ( label , readSetting ( ) , defaultCheckboxStyles ) ) ;
396
414
container . appendChild ( settingCheckbox . domNode ) ;
@@ -414,7 +432,7 @@ export class ChatStatusBarEntry extends Disposable implements IWorkbenchContribu
414
432
} ) ) ;
415
433
416
434
disposables . add ( this . configurationService . onDidChangeConfiguration ( e => {
417
- if ( e . affectsConfiguration ( setting . key , { overrideIdentifier : setting . override } ) ) {
435
+ if ( e . affectsConfiguration ( settingId ) ) {
418
436
settingCheckbox . checked = readSetting ( ) ;
419
437
}
420
438
} ) ) ;
0 commit comments