mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 02:01:29 +00:00
fix: align input editor with message content padding
Adds paddingX option to Editor component and hardcodes paddingX: 1 in coding-agent editors so the cursor/text aligns with chat message content.
This commit is contained in:
parent
20f5fcc79d
commit
48ea444bc4
7 changed files with 48 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Editor, type EditorTheme, type TUI } from "@mariozechner/pi-tui";
|
||||
import { Editor, type EditorOptions, type EditorTheme, type TUI } from "@mariozechner/pi-tui";
|
||||
import type { AppAction, KeybindingsManager } from "../../../core/keybindings.js";
|
||||
|
||||
/**
|
||||
|
|
@ -15,8 +15,8 @@ export class CustomEditor extends Editor {
|
|||
/** Handler for extension-registered shortcuts. Returns true if handled. */
|
||||
public onExtensionShortcut?: (data: string) => boolean;
|
||||
|
||||
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager) {
|
||||
super(tui, theme);
|
||||
constructor(tui: TUI, theme: EditorTheme, keybindings: KeybindingsManager, options?: EditorOptions) {
|
||||
super(tui, theme, options);
|
||||
this.keybindings = keybindings;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,15 @@ import { spawnSync } from "node:child_process";
|
|||
import * as fs from "node:fs";
|
||||
import * as os from "node:os";
|
||||
import * as path from "node:path";
|
||||
import { Container, Editor, getEditorKeybindings, Spacer, Text, type TUI } from "@mariozechner/pi-tui";
|
||||
import {
|
||||
Container,
|
||||
Editor,
|
||||
type EditorOptions,
|
||||
getEditorKeybindings,
|
||||
Spacer,
|
||||
Text,
|
||||
type TUI,
|
||||
} from "@mariozechner/pi-tui";
|
||||
import type { KeybindingsManager } from "../../../core/keybindings.js";
|
||||
import { getEditorTheme, theme } from "../theme/theme.js";
|
||||
import { DynamicBorder } from "./dynamic-border.js";
|
||||
|
|
@ -27,6 +35,7 @@ export class ExtensionEditorComponent extends Container {
|
|||
prefill: string | undefined,
|
||||
onSubmit: (value: string) => void,
|
||||
onCancel: () => void,
|
||||
options?: EditorOptions,
|
||||
) {
|
||||
super();
|
||||
|
||||
|
|
@ -44,7 +53,7 @@ export class ExtensionEditorComponent extends Container {
|
|||
this.addChild(new Spacer(1));
|
||||
|
||||
// Create editor
|
||||
this.editor = new Editor(tui, getEditorTheme());
|
||||
this.editor = new Editor(tui, getEditorTheme(), options);
|
||||
if (prefill) {
|
||||
this.editor.setText(prefill);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ export class InteractiveMode {
|
|||
this.statusContainer = new Container();
|
||||
this.widgetContainer = new Container();
|
||||
this.keybindings = KeybindingsManager.create();
|
||||
this.defaultEditor = new CustomEditor(this.ui, getEditorTheme(), this.keybindings);
|
||||
this.defaultEditor = new CustomEditor(this.ui, getEditorTheme(), this.keybindings, { paddingX: 1 });
|
||||
this.editor = this.defaultEditor;
|
||||
this.editorContainer = new Container();
|
||||
this.editorContainer.addChild(this.editor as Component);
|
||||
|
|
@ -1150,6 +1150,7 @@ export class InteractiveMode {
|
|||
this.hideExtensionEditor();
|
||||
resolve(undefined);
|
||||
},
|
||||
{ paddingX: 1 },
|
||||
);
|
||||
|
||||
this.editorContainer.clear();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue