fix(cli): prompt for editor selection when CTRL-X is pressed and none is configured

This commit is contained in:
A.K.M. Adib
2026-05-04 15:24:25 -04:00
parent 60a6a47d56
commit a7d49971d2
2 changed files with 17 additions and 2 deletions
@@ -12,6 +12,7 @@ import { useState, useCallback, useEffect, useMemo, useReducer } from 'react';
import { LRUCache } from 'mnemonist';
import {
coreEvents,
CoreEvent,
debugLogger,
unescapePath,
type EditorType,
@@ -29,7 +30,10 @@ import { Command } from '../../key/keyMatchers.js';
import type { VimAction } from './vim-buffer-actions.js';
import { handleVimAction } from './vim-buffer-actions.js';
import { LRU_BUFFER_PERF_CACHE_LIMIT } from '../../constants.js';
import { openFileInEditor } from '../../utils/editorUtils.js';
import {
openFileInEditor,
EditorNotConfiguredError,
} from '../../utils/editorUtils.js';
import { useKeyMatchers } from '../../hooks/useKeyMatchers.js';
export const LARGE_PASTE_LINE_THRESHOLD = 5;
@@ -3342,6 +3346,10 @@ export function useTextBuffer({
dispatch({ type: 'set_text', payload: newText, pushToUndo: false });
} catch (err) {
if (err instanceof EditorNotConfiguredError) {
coreEvents.emit(CoreEvent.RequestEditorSelection);
return;
}
coreEvents.emitFeedback(
'error',
'[useTextBuffer] external editor error',
+8 -1
View File
@@ -15,6 +15,13 @@ import {
isTerminalEditor,
} from '@google/gemini-cli-core';
export class EditorNotConfiguredError extends Error {
constructor() {
super('No external editor configured');
this.name = 'EditorNotConfiguredError';
}
}
/**
* Opens a file in an external editor and waits for it to close.
* Handles raw mode switching to ensure the editor can interact with the terminal.
@@ -58,7 +65,7 @@ export async function openFileInEditor(
}
if (!command) {
command = process.platform === 'win32' ? 'notepad' : 'vi';
throw new EditorNotConfiguredError();
}
const [executable = '', ...initialArgs] = command.split(' ');