feat(coding-agent): add external editor setting

Closes #6122
This commit is contained in:
Armin Ronacher
2026-06-27 23:57:46 +02:00
parent f2e9d75388
commit 5a073885b5
9 changed files with 91 additions and 9 deletions
@@ -28,6 +28,7 @@ export class ExtensionEditorComponent extends Container implements Focusable {
private onCancelCallback: () => void;
private tui: TUI;
private keybindings: KeybindingsManager;
private externalEditorCommand: string | undefined;
private _focused = false;
get focused(): boolean {
@@ -46,11 +47,13 @@ export class ExtensionEditorComponent extends Container implements Focusable {
onSubmit: (value: string) => void,
onCancel: () => void,
options?: EditorOptions,
externalEditorCommand?: string,
) {
super();
this.tui = tui;
this.keybindings = keybindings;
this.externalEditorCommand = externalEditorCommand;
this.onSubmitCallback = onSubmit;
this.onCancelCallback = onCancel;
@@ -76,7 +79,7 @@ export class ExtensionEditorComponent extends Container implements Focusable {
this.addChild(new Spacer(1));
// Add hint
const hasExternalEditor = !!(process.env.VISUAL || process.env.EDITOR);
const hasExternalEditor = !!this.getExternalEditorCommand();
const hint =
keyHint("tui.select.confirm", "submit") +
" " +
@@ -110,8 +113,16 @@ export class ExtensionEditorComponent extends Container implements Focusable {
this.editor.handleInput(keyData);
}
private getExternalEditorCommand(): string | undefined {
const editorCmd = this.externalEditorCommand || process.env.VISUAL || process.env.EDITOR;
if (editorCmd) {
return editorCmd;
}
return process.platform === "win32" ? "notepad" : "nano";
}
private async openExternalEditor(): Promise<void> {
const editorCmd = process.env.VISUAL || process.env.EDITOR;
const editorCmd = this.getExternalEditorCommand();
if (!editorCmd) {
return;
}