Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nes - ensure to read/write setting value from status with text config service #244881

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/editor/common/services/textResourceConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>;
updateValue(resource: URI | undefined, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise<void>;

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
const language = this.getLanguage(resource, null);
updateValue(resource: URI | undefined, key: string, value: any, configurationTarget?: ConfigurationTarget): Promise<void> {
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);
Expand Down
15 changes: 6 additions & 9 deletions src/vs/workbench/contrib/chat/browser/chatStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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<boolean>(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<boolean>(resource, nesSettingId),
writeSetting: (value: boolean) => this.textResourceConfigurationService.updateValue(resource, nesSettingId, value)
}, disposables);

// enablement of NES depends on completions setting
Expand Down
Loading