Skip to content

Commit 9f0637d

Browse files
authored
Enable Copilot from chat extension (#1758)
* contibute copilot enabled from chat extension * Make github.copilot.enable contributed by chat extension
1 parent 8464add commit 9f0637d

File tree

6 files changed

+31
-16
lines changed

6 files changed

+31
-16
lines changed

package.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"icon": "assets/copilot.png",
2424
"pricing": "Trial",
2525
"engines": {
26-
"vscode": "^1.106.0-20251030",
26+
"vscode": "^1.106.0-20251103",
2727
"npm": ">=9.0.0",
2828
"node": ">=22.14.0"
2929
},
@@ -2440,6 +2440,20 @@
24402440
"type": "boolean",
24412441
"default": true,
24422442
"description": "%github.copilot.config.agent.currentEditorContext.enabled%"
2443+
},
2444+
"github.copilot.enable": {
2445+
"type": "object",
2446+
"scope": "window",
2447+
"default": {
2448+
"*": true,
2449+
"plaintext": false,
2450+
"markdown": false,
2451+
"scminput": false
2452+
},
2453+
"additionalProperties": {
2454+
"type": "boolean"
2455+
},
2456+
"markdownDescription": "Enable or disable auto triggering of Copilot completions for specified [languages](https://code.visualstudio.com/docs/languages/identifiers). You can still trigger suggestions manually using `Alt + \\`"
24432457
}
24442458
}
24452459
},

src/extension/inlineEdits/test/vscode-node/documentFilter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ describe('DocumentFilter', () => {
3939

4040
it('can react to copilot.enable config changes for off-by-default language id', async () => {
4141
const defaultsConfigService = new DefaultsOnlyConfigurationService();
42-
const defaultConfig = defaultsConfigService.getConfig(ConfigKey.Shared.Enable);
42+
const defaultConfig = defaultsConfigService.getConfig(ConfigKey.Enable);
4343
const configService = new InMemoryConfigurationService(defaultsConfigService);
4444
const documentFilter = new DocumentFilter(ignoreService, configService);
4545
const doc = createDoc('markdown');
4646

4747
const isEnabled0 = await documentFilter.isTrackingEnabled(doc);
4848
expect(isEnabled0).toBe(false);
4949

50-
configService.setConfig(ConfigKey.Shared.Enable, {
50+
configService.setConfig(ConfigKey.Enable, {
5151
...defaultConfig,
5252
'markdown': true,
5353
});
@@ -58,10 +58,10 @@ describe('DocumentFilter', () => {
5858

5959
it('can react to copilot.enable config changes for javascript', async () => {
6060
const defaultsConfigService = new DefaultsOnlyConfigurationService();
61-
const defaultConfig = defaultsConfigService.getConfig(ConfigKey.Shared.Enable);
61+
const defaultConfig = defaultsConfigService.getConfig(ConfigKey.Enable);
6262
const configService = new InMemoryConfigurationService(defaultsConfigService, new Map(
6363
[
64-
[ConfigKey.Shared.Enable, {
64+
[ConfigKey.Enable, {
6565
...defaultConfig,
6666
[js]: false,
6767
}],
@@ -73,7 +73,7 @@ describe('DocumentFilter', () => {
7373
const isEnabled0 = await documentFilter.isTrackingEnabled(doc);
7474
expect(isEnabled0).toBe(false);
7575

76-
configService.setConfig(ConfigKey.Shared.Enable, {
76+
configService.setConfig(ConfigKey.Enable, {
7777
...defaultConfig,
7878
[js]: true,
7979
});

src/extension/inlineEdits/vscode-node/inlineCompletionProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class InlineCompletionProviderImpl implements InlineCompletionItemProvide
126126

127127
// copied from `vscodeWorkspace.ts` `DocumentFilter#_enabledLanguages`
128128
private _isCompletionsEnabled(document: TextDocument): boolean {
129-
const enabledLanguages = this._configurationService.getConfig(ConfigKey.Shared.Enable);
129+
const enabledLanguages = this._configurationService.getConfig(ConfigKey.Enable);
130130
const enabledLanguagesMap = new Map(Object.entries(enabledLanguages));
131131
if (!enabledLanguagesMap.has('*')) {
132132
enabledLanguagesMap.set('*', false);

src/extension/inlineEdits/vscode-node/parts/documentFilter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class DocumentFilter {
1717
@IIgnoreService private readonly _ignoreService: IIgnoreService,
1818
@IConfigurationService private readonly _configurationService: IConfigurationService
1919
) {
20-
this._enabledLanguagesObs = this._configurationService.getConfigObservable(ConfigKey.Shared.Enable);
20+
this._enabledLanguagesObs = this._configurationService.getConfigObservable(ConfigKey.Enable);
2121
this._ignoreCompletionsDisablement = this._configurationService.getConfigObservable(ConfigKey.Internal.InlineEditsIgnoreCompletionsDisablement);
2222
}
2323

src/platform/configuration/common/configurationService.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,6 @@ export namespace ConfigKey {
586586
export const DebugUseElectronFetcher = defineSetting('advanced.debug.useElectronFetcher', true);
587587
export const AuthProvider = defineSetting<AuthProviderId>('advanced.authProvider', AuthProviderId.GitHub);
588588
export const AuthPermissions = defineSetting<AuthPermissionMode>('advanced.authPermissions', AuthPermissionMode.Default);
589-
export const Enable = defineSetting<{ [key: string]: boolean }>('enable', {
590-
"*": true,
591-
"plaintext": false,
592-
"markdown": false,
593-
"scminput": false
594-
});
595589
}
596590

597591
/**
@@ -750,6 +744,13 @@ export namespace ConfigKey {
750744
export const Gpt5AlternativePatch = defineExpSetting<boolean>('chat.advanced.gpt5AlternativePatch', false);
751745
}
752746

747+
export const Enable = defineSetting<{ [key: string]: boolean }>('enable', {
748+
"*": true,
749+
"plaintext": false,
750+
"markdown": false,
751+
"scminput": false
752+
});
753+
753754
/** Use the Responses API instead of Chat Completions when supported */
754755
export const UseResponsesApi = defineExpSetting<boolean | undefined>('chat.useResponsesApi', true);
755756
/** Configure reasoning effort sent to Responses API */

src/platform/inlineEdits/common/nesActivationStatusTelemetry.contribution.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ export class NesActivationTelemetryContribution {
1414
@IConfigurationService _configurationService: IConfigurationService,
1515
@IExperimentationService _expService: IExperimentationService,
1616
) {
17-
const completionsConfigValue = _configurationService.getConfig(ConfigKey.Shared.Enable);
17+
const completionsConfigValue = _configurationService.getConfig(ConfigKey.Enable);
1818
const isCompletionsEnabled = '*' in completionsConfigValue ? completionsConfigValue['*'] : true /* matches ghost-text Copilot extensions behavior */;
19-
const isCompletionsUserConfigured = _configurationService.isConfigured(ConfigKey.Shared.Enable);
19+
const isCompletionsUserConfigured = _configurationService.isConfigured(ConfigKey.Enable);
2020

2121
const isNesEnabled = _configurationService.getExperimentBasedConfig(ConfigKey.InlineEditsEnabled, _expService);
2222
const isNesUserConfigured = _configurationService.isConfigured(ConfigKey.InlineEditsEnabled);

0 commit comments

Comments
 (0)