Skip to content
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
11 changes: 11 additions & 0 deletions packages/cli/src/config/settingPaths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

export const SettingPaths = {
General: {
PreferredEditor: 'general.preferredEditor',
},
} as const;
Comment thread
abhipatel12 marked this conversation as resolved.
3 changes: 2 additions & 1 deletion packages/cli/src/config/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { resolveEnvVarsInObject } from '../utils/envVarResolver.js';
import { customDeepMerge, type MergeableObject } from '../utils/deepMerge.js';
import { updateSettingsFilePreservingFormat } from '../utils/commentJson.js';
import type { ExtensionManager } from './extension-manager.js';
import { SettingPaths } from './settingPaths.js';

function getMergeStrategyForPath(path: string[]): MergeStrategy | undefined {
let current: SettingDefinition | undefined = undefined;
Expand Down Expand Up @@ -108,7 +109,7 @@ const MIGRATION_MAP: Record<string, string> = {
memoryImportFormat: 'context.importFormat',
memoryDiscoveryMaxDirs: 'context.discoveryMaxDirs',
model: 'model.name',
preferredEditor: 'general.preferredEditor',
preferredEditor: SettingPaths.General.PreferredEditor,
Comment thread
abhipatel12 marked this conversation as resolved.
retryFetchErrors: 'general.retryFetchErrors',
sandbox: 'tools.sandbox',
selectedAuthType: 'security.auth.selectedType',
Expand Down
10 changes: 6 additions & 4 deletions packages/cli/src/ui/hooks/useEditorSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
allowEditorTypeInSandbox,
} from '@google/gemini-cli-core';

import { SettingPaths } from '../../config/settingPaths.js';

vi.mock('@google/gemini-cli-core', async () => {
const actual = await vi.importActual('@google/gemini-cli-core');
return {
Expand Down Expand Up @@ -114,7 +116,7 @@ describe('useEditorSettings', () => {

expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
scope,
'preferredEditor',
SettingPaths.General.PreferredEditor,
Comment thread
abhipatel12 marked this conversation as resolved.
editorType,
);

Expand Down Expand Up @@ -142,7 +144,7 @@ describe('useEditorSettings', () => {

expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
scope,
'preferredEditor',
SettingPaths.General.PreferredEditor,
Comment thread
abhipatel12 marked this conversation as resolved.
undefined,
);

Expand Down Expand Up @@ -171,7 +173,7 @@ describe('useEditorSettings', () => {

expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
scope,
'preferredEditor',
SettingPaths.General.PreferredEditor,
Comment thread
abhipatel12 marked this conversation as resolved.
editorType,
);

Expand Down Expand Up @@ -201,7 +203,7 @@ describe('useEditorSettings', () => {

expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
scope,
'preferredEditor',
SettingPaths.General.PreferredEditor,
Comment thread
abhipatel12 marked this conversation as resolved.
editorType,
);

Expand Down
8 changes: 7 additions & 1 deletion packages/cli/src/ui/hooks/useEditorSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
checkHasEditorType,
} from '@google/gemini-cli-core';

import { SettingPaths } from '../../config/settingPaths.js';

interface UseEditorSettingsReturn {
isEditorDialogOpen: boolean;
openEditorDialog: () => void;
Expand Down Expand Up @@ -48,7 +50,11 @@ export const useEditorSettings = (
}

try {
loadedSettings.setValue(scope, 'preferredEditor', editorType);
loadedSettings.setValue(
scope,
SettingPaths.General.PreferredEditor,
editorType,
);
Comment thread
abhipatel12 marked this conversation as resolved.
addItem(
{
type: MessageType.INFO,
Expand Down