mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-15 06:12:50 -07:00
fix(cli): prompt for editor selection when CTRL-X is pressed and none is configured
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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(' ');
|
||||
|
||||
Reference in New Issue
Block a user