fix: resolve infinite loop when using 'Modify with external editor' (#17453)

Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
Co-authored-by: ehedlund <ehedlund@google.com>
This commit is contained in:
Philippe
2026-02-05 21:52:41 +01:00
committed by GitHub
parent 8efae719ee
commit 2498114df6
8 changed files with 336 additions and 51 deletions
@@ -24,7 +24,7 @@ import { SettingScope } from '../../config/settings.js';
import { MessageType } from '../types.js';
import {
type EditorType,
checkHasEditorType,
hasValidEditorCommand,
allowEditorTypeInSandbox,
} from '@google/gemini-cli-core';
import type { UseHistoryManagerReturn } from './useHistoryManager.js';
@@ -35,12 +35,12 @@ vi.mock('@google/gemini-cli-core', async () => {
const actual = await vi.importActual('@google/gemini-cli-core');
return {
...actual,
checkHasEditorType: vi.fn(() => true),
hasValidEditorCommand: vi.fn(() => true),
allowEditorTypeInSandbox: vi.fn(() => true),
};
});
const mockCheckHasEditorType = vi.mocked(checkHasEditorType);
const mockHasValidEditorCommand = vi.mocked(hasValidEditorCommand);
const mockAllowEditorTypeInSandbox = vi.mocked(allowEditorTypeInSandbox);
describe('useEditorSettings', () => {
@@ -69,7 +69,7 @@ describe('useEditorSettings', () => {
mockAddItem = vi.fn();
// Reset mock implementations to default
mockCheckHasEditorType.mockReturnValue(true);
mockHasValidEditorCommand.mockReturnValue(true);
mockAllowEditorTypeInSandbox.mockReturnValue(true);
});
@@ -224,7 +224,7 @@ describe('useEditorSettings', () => {
it('should not set preference for unavailable editors', () => {
render(<TestComponent />);
mockCheckHasEditorType.mockReturnValue(false);
mockHasValidEditorCommand.mockReturnValue(false);
const editorType: EditorType = 'vscode';
const scope = SettingScope.User;