mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-23 04:26:05 +00:00
fix(tui): keep wrapped tool rows dense
This commit is contained in:
parent
eb5d30257a
commit
c9426d3a57
2 changed files with 13 additions and 14 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue