fix(tui): render explicit prompt gap

Reserve the composer prompt gap as layout instead of relying on terminal handling of trailing spaces.
This commit is contained in:
Brooklyn Nicholson 2026-04-29 15:25:06 -05:00
parent 456955c2e4
commit 10fcd620d2
3 changed files with 50 additions and 9 deletions

View file

@ -1,7 +1,7 @@
import { describe, expect, it } from 'vitest'
import { offsetFromPosition } from '../components/textInput.js'
import { cursorLayout, inputVisualHeight, stableComposerColumns } from '../lib/inputMetrics.js'
import { composerPromptWidth, cursorLayout, inputVisualHeight, stableComposerColumns } from '../lib/inputMetrics.js'
describe('cursorLayout — char-wrap parity with wrap-ansi', () => {
it('places cursor mid-line at its column', () => {
@ -42,6 +42,12 @@ describe('input metrics helpers', () => {
expect(inputVisualHeight('one\ntwo', 40)).toBe(2)
})
it('counts the prompt gap as its own cell', () => {
expect(composerPromptWidth('>')).toBe(2)
expect(composerPromptWidth('')).toBe(2)
expect(composerPromptWidth('Ψ >')).toBe(4)
})
it('reserves gutters on wide panes without starving narrow composer width', () => {
expect(stableComposerColumns(100, 3)).toBe(93)
expect(stableComposerColumns(100, 5)).toBe(91)