Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions editor-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,6 @@ function stripOuterFrameAndPadding(line: string, paddingX: number): string {
* add side borders and padding. The queue already provides that frame, so an
* active row should inherit only the live editor content and cursor.
*/
/**
* Keep an editor's top border only when it carries an embedded status such as
* Pi's working spinner, so the status stays visible while a queued row is edited inline.
*/
export function extractEmbeddedStatusBorder(lines: readonly string[]): string[] {
const top = lines[0] ?? "";
const label = stripAnsi(top).replace(/↑ \d+ more/, "").replace(/─/g, "").trim();
return label ? [top] : [];
}

export function extractInlineEditorLines(lines: readonly string[], paddingX = 0): string[] {
if (lines.length === 0) return [""];
if (!isEditorFrame(lines[0] ?? "")) return [...lines];
Expand All @@ -157,3 +147,9 @@ export function extractInlineEditorLines(lines: readonly string[], paddingX = 0)
const auxiliary = lines.slice(bottomFrameIndex + 1);
return [...editorBody, ...auxiliary].length > 0 ? [...editorBody, ...auxiliary] : [""];
}

/** Keep the editor's top border only while it carries an embedded status such as Pi's working spinner. */
export function extractEmbeddedStatusBorder([top = ""]: readonly string[]): string[] {
const label = stripAnsi(top).replace(/↑ \d+ more/, "").replace(/─/g, "").trim();
return label ? [top] : [];
}
10 changes: 3 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,7 @@ export default function queueSteerExtension(pi: ExtensionAPI) {
if (features.has(QUEUE_STEER_FEATURE)) return;

const factory = ((tui, theme, keybindings) => {
const editor = previousFactory?.(tui, theme, keybindings) ?? new CustomEditor(tui, theme, keybindings, {
embedWorkingStatus: true,
});
const editor = previousFactory?.(tui, theme, keybindings) ?? new CustomEditor(tui, theme, keybindings, { embedWorkingStatus: true });
installSubmitGuard(editor, ctx);
const handleInput = editor.handleInput.bind(editor);
const renderEditor = editor.render.bind(editor);
Expand All @@ -606,10 +604,8 @@ export default function queueSteerExtension(pi: ExtensionAPI) {

const embedsWorkingStatus = "embedWorkingStatus" in editor && editor.embedWorkingStatus === true;
editor.render = (width: number): string[] => {
if (editSession && !renderingInline) {
return embedsWorkingStatus ? extractEmbeddedStatusBorder(renderEditor(width)) : [];
}
return renderEditor(width);
if (!editSession || renderingInline) return renderEditor(width);
return embedsWorkingStatus ? extractEmbeddedStatusBorder(renderEditor(width)) : [];
};

editor.handleInput = (data: string): void => {
Expand Down
Loading