fix(tui): keep wrapped tool rows dense

This commit is contained in:
Kit Langton 2026-05-21 15:04:41 -04:00
parent eb5d30257a
commit c9426d3a57
2 changed files with 13 additions and 14 deletions

View file

@ -1780,21 +1780,10 @@ function InlineTool(props: {
if (!parent) {
return
}
if (el.height > 1) {
setMargin(1)
return
}
const children = parent.getChildren()
const index = children.indexOf(el)
const previous = children[index - 1]
if (!previous) {
setMargin(0)
return
}
if (previous.height > 1 || previous.id.startsWith("text-")) {
setMargin(1)
return
}
setMargin(previous?.id.startsWith("text-") ? 1 : 0)
}}
>
<Switch>

View file

@ -1,5 +1,5 @@
import { afterEach, describe, expect, test } from "bun:test"
import { For } from "solid-js"
import { createSignal, For } from "solid-js"
import { testRender } from "@opentui/solid"
let testSetup: Awaited<ReturnType<typeof testRender>> | undefined
@ -38,8 +38,18 @@ const tools: readonly ToolFixture[] = [
] as const
function InlineToolRow(props: { item: ToolFixture }) {
const [margin, setMargin] = createSignal(0)
return (
<box paddingLeft={3}>
<box
marginTop={margin()}
paddingLeft={3}
renderBefore={function () {
const parent = this.parent
if (!parent) return
setMargin(parent.getChildren()[parent.getChildren().indexOf(this) - 1]?.id.startsWith("text-") ? 1 : 0)
}}
>
<box flexDirection="row">
<text width={props.item.icon.length + 1}>{props.item.icon}</text>
<text flexGrow={1}>{props.item.label}</text>