feat(cli): add Sublime Text and Emacs Client editors, improve error messages and documentation (#21090)

Co-authored-by: Ananth Kini <ananthkini1@gmail.com>
This commit is contained in:
Andrea Alberti
2026-05-19 22:03:25 +02:00
committed by GitHub
parent 8997488ea6
commit 57c42a5c40
11 changed files with 527 additions and 85 deletions
@@ -13,6 +13,7 @@ import { LRUCache } from 'mnemonist';
import {
coreEvents,
debugLogger,
getErrorMessage,
unescapePath,
type EditorType,
} from '@google/gemini-cli-core';
@@ -30,6 +31,7 @@ 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 { useSettings } from '../../contexts/SettingsContext.js';
import { useKeyMatchers } from '../../hooks/useKeyMatchers.js';
export const LARGE_PASTE_LINE_THRESHOLD = 5;
@@ -2840,6 +2842,7 @@ export function useTextBuffer({
singleLine = false,
getPreferredEditor,
}: UseTextBufferProps): TextBuffer {
const settings = useSettings();
const keyMatchers = useKeyMatchers();
const initialState = useMemo((): TextBufferState => {
const lines = initialText.split('\n');
@@ -3325,6 +3328,7 @@ export function useTextBuffer({
stdin,
setRawMode,
getPreferredEditor?.(),
settings.merged.general.openEditorInNewWindow,
);
let newText = fs.readFileSync(filePath, 'utf8');
@@ -3342,11 +3346,7 @@ export function useTextBuffer({
dispatch({ type: 'set_text', payload: newText, pushToUndo: false });
} catch (err) {
coreEvents.emitFeedback(
'error',
'[useTextBuffer] external editor error',
err,
);
coreEvents.emitFeedback('error', getErrorMessage(err), err);
} finally {
try {
fs.unlinkSync(filePath);
@@ -3359,7 +3359,14 @@ export function useTextBuffer({
/* ignore */
}
}
}, [text, pastedContent, stdin, setRawMode, getPreferredEditor]);
}, [
text,
pastedContent,
stdin,
setRawMode,
getPreferredEditor,
settings.merged.general.openEditorInNewWindow,
]);
const handleInput = useCallback(
(key: Key): boolean => {