mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-11 22:51:00 -07:00
fix(editor): ensure preferred editor setting updates immediately (#12981)
This commit is contained in:
11
packages/cli/src/config/settingPaths.ts
Normal file
11
packages/cli/src/config/settingPaths.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* @license
|
||||||
|
* Copyright 2025 Google LLC
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
export const SettingPaths = {
|
||||||
|
General: {
|
||||||
|
PreferredEditor: 'general.preferredEditor',
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
@@ -33,6 +33,7 @@ import { resolveEnvVarsInObject } from '../utils/envVarResolver.js';
|
|||||||
import { customDeepMerge, type MergeableObject } from '../utils/deepMerge.js';
|
import { customDeepMerge, type MergeableObject } from '../utils/deepMerge.js';
|
||||||
import { updateSettingsFilePreservingFormat } from '../utils/commentJson.js';
|
import { updateSettingsFilePreservingFormat } from '../utils/commentJson.js';
|
||||||
import type { ExtensionManager } from './extension-manager.js';
|
import type { ExtensionManager } from './extension-manager.js';
|
||||||
|
import { SettingPaths } from './settingPaths.js';
|
||||||
|
|
||||||
function getMergeStrategyForPath(path: string[]): MergeStrategy | undefined {
|
function getMergeStrategyForPath(path: string[]): MergeStrategy | undefined {
|
||||||
let current: SettingDefinition | undefined = undefined;
|
let current: SettingDefinition | undefined = undefined;
|
||||||
@@ -108,7 +109,7 @@ const MIGRATION_MAP: Record<string, string> = {
|
|||||||
memoryImportFormat: 'context.importFormat',
|
memoryImportFormat: 'context.importFormat',
|
||||||
memoryDiscoveryMaxDirs: 'context.discoveryMaxDirs',
|
memoryDiscoveryMaxDirs: 'context.discoveryMaxDirs',
|
||||||
model: 'model.name',
|
model: 'model.name',
|
||||||
preferredEditor: 'general.preferredEditor',
|
preferredEditor: SettingPaths.General.PreferredEditor,
|
||||||
retryFetchErrors: 'general.retryFetchErrors',
|
retryFetchErrors: 'general.retryFetchErrors',
|
||||||
sandbox: 'tools.sandbox',
|
sandbox: 'tools.sandbox',
|
||||||
selectedAuthType: 'security.auth.selectedType',
|
selectedAuthType: 'security.auth.selectedType',
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import {
|
|||||||
allowEditorTypeInSandbox,
|
allowEditorTypeInSandbox,
|
||||||
} from '@google/gemini-cli-core';
|
} from '@google/gemini-cli-core';
|
||||||
|
|
||||||
|
import { SettingPaths } from '../../config/settingPaths.js';
|
||||||
|
|
||||||
vi.mock('@google/gemini-cli-core', async () => {
|
vi.mock('@google/gemini-cli-core', async () => {
|
||||||
const actual = await vi.importActual('@google/gemini-cli-core');
|
const actual = await vi.importActual('@google/gemini-cli-core');
|
||||||
return {
|
return {
|
||||||
@@ -114,7 +116,7 @@ describe('useEditorSettings', () => {
|
|||||||
|
|
||||||
expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
|
expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
|
||||||
scope,
|
scope,
|
||||||
'preferredEditor',
|
SettingPaths.General.PreferredEditor,
|
||||||
editorType,
|
editorType,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -142,7 +144,7 @@ describe('useEditorSettings', () => {
|
|||||||
|
|
||||||
expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
|
expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
|
||||||
scope,
|
scope,
|
||||||
'preferredEditor',
|
SettingPaths.General.PreferredEditor,
|
||||||
undefined,
|
undefined,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -171,7 +173,7 @@ describe('useEditorSettings', () => {
|
|||||||
|
|
||||||
expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
|
expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
|
||||||
scope,
|
scope,
|
||||||
'preferredEditor',
|
SettingPaths.General.PreferredEditor,
|
||||||
editorType,
|
editorType,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -201,7 +203,7 @@ describe('useEditorSettings', () => {
|
|||||||
|
|
||||||
expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
|
expect(mockLoadedSettings.setValue).toHaveBeenCalledWith(
|
||||||
scope,
|
scope,
|
||||||
'preferredEditor',
|
SettingPaths.General.PreferredEditor,
|
||||||
editorType,
|
editorType,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import {
|
|||||||
checkHasEditorType,
|
checkHasEditorType,
|
||||||
} from '@google/gemini-cli-core';
|
} from '@google/gemini-cli-core';
|
||||||
|
|
||||||
|
import { SettingPaths } from '../../config/settingPaths.js';
|
||||||
|
|
||||||
interface UseEditorSettingsReturn {
|
interface UseEditorSettingsReturn {
|
||||||
isEditorDialogOpen: boolean;
|
isEditorDialogOpen: boolean;
|
||||||
openEditorDialog: () => void;
|
openEditorDialog: () => void;
|
||||||
@@ -48,7 +50,11 @@ export const useEditorSettings = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadedSettings.setValue(scope, 'preferredEditor', editorType);
|
loadedSettings.setValue(
|
||||||
|
scope,
|
||||||
|
SettingPaths.General.PreferredEditor,
|
||||||
|
editorType,
|
||||||
|
);
|
||||||
addItem(
|
addItem(
|
||||||
{
|
{
|
||||||
type: MessageType.INFO,
|
type: MessageType.INFO,
|
||||||
|
|||||||
Reference in New Issue
Block a user