From 769a49e314c2adbba35d9bf13d756d0a4217ec79 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 27 Mar 2025 16:39:39 +0100 Subject: [PATCH] nes - ensure to read/write setting value from status with text config service (#244881) --- .../common/services/textResourceConfiguration.ts | 2 +- .../services/textResourceConfigurationService.ts | 4 ++-- .../workbench/contrib/chat/browser/chatStatus.ts | 15 ++++++--------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/vs/editor/common/services/textResourceConfiguration.ts b/src/vs/editor/common/services/textResourceConfiguration.ts index f2edf685f2b..da2c0a8b653 100644 --- a/src/vs/editor/common/services/textResourceConfiguration.ts +++ b/src/vs/editor/common/services/textResourceConfiguration.ts @@ -72,7 +72,7 @@ export interface ITextResourceConfigurationService { * @param configurationTarget Optional target into which the configuration has to be updated. * If not specified, target will be derived by checking where the configuration is defined. */ - updateValue(resource: URI, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise; + updateValue(resource: URI | undefined, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise; } diff --git a/src/vs/editor/common/services/textResourceConfigurationService.ts b/src/vs/editor/common/services/textResourceConfigurationService.ts index b8534a81e6c..04420d7f5e6 100644 --- a/src/vs/editor/common/services/textResourceConfigurationService.ts +++ b/src/vs/editor/common/services/textResourceConfigurationService.ts @@ -37,8 +37,8 @@ export class TextResourceConfigurationService extends Disposable implements ITex return this._getValue(resource, null, typeof arg2 === 'string' ? arg2 : undefined); } - updateValue(resource: URI, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise { - const language = this.getLanguage(resource, null); + updateValue(resource: URI | undefined, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise { + const language = resource ? this.getLanguage(resource, null) : null; const configurationValue = this.configurationService.inspect(key, { resource, overrideIdentifier: language }); if (configurationTarget === undefined) { configurationTarget = this.deriveConfigurationTarget(configurationValue, language); diff --git a/src/vs/workbench/contrib/chat/browser/chatStatus.ts b/src/vs/workbench/contrib/chat/browser/chatStatus.ts index 432a7858a3c..34a04f7c40b 100644 --- a/src/vs/workbench/contrib/chat/browser/chatStatus.ts +++ b/src/vs/workbench/contrib/chat/browser/chatStatus.ts @@ -35,6 +35,8 @@ import { Link } from '../../../../platform/opener/browser/link.js'; import { IOpenerService } from '../../../../platform/opener/common/opener.js'; import { ITelemetryService } from '../../../../platform/telemetry/common/telemetry.js'; import { IChatStatusItemService, ChatStatusEntry } from './chatStatusItemService.js'; +import { ITextResourceConfigurationService } from '../../../../editor/common/services/textResourceConfiguration.js'; +import { EditorResourceAccessor, SideBySideEditor } from '../../../common/editor.js'; const gaugeBackground = registerColor('gauge.background', { dark: inputValidationInfoBorder, @@ -249,6 +251,7 @@ class ChatStatusDashboard extends Disposable { @ILanguageService private readonly languageService: ILanguageService, @IOpenerService private readonly openerService: IOpenerService, @ITelemetryService private readonly telemetryService: ITelemetryService, + @ITextResourceConfigurationService private readonly textResourceConfigurationService: ITextResourceConfigurationService, ) { super(); } @@ -516,17 +519,11 @@ class ChatStatusDashboard extends Disposable { private createNextEditSuggestionsSetting(container: HTMLElement, label: string, modeId: string | undefined, completionsSettingAccessor: ISettingsAccessor, disposables: DisposableStore): void { const nesSettingId = defaultChat.nextEditSuggestionsSetting; const completionsSettingId = defaultChat.completionsEnablementSetting; + const resource = EditorResourceAccessor.getOriginalUri(this.editorService.activeEditor, { supportSideBySide: SideBySideEditor.PRIMARY }); const checkbox = this.createSetting(container, nesSettingId, label, { - readSetting: () => this.configurationService.getValue(nesSettingId, { overrideIdentifier: modeId }), - writeSetting: (value: boolean) => { - const { overrideIdentifiers } = this.configurationService.inspect(nesSettingId, { overrideIdentifier: modeId }); - if (modeId && overrideIdentifiers?.includes(modeId)) { - return this.configurationService.updateValue(nesSettingId, value, { overrideIdentifier: modeId }); - } - - return this.configurationService.updateValue(nesSettingId, value); - } + readSetting: () => this.textResourceConfigurationService.getValue(resource, nesSettingId), + writeSetting: (value: boolean) => this.textResourceConfigurationService.updateValue(resource, nesSettingId, value) }, disposables); // enablement of NES depends on completions setting