Render a choice's whole list item inside its pick box

This commit is contained in:
Ian Gulliver
2026-10-15 11:46:24 -07:00
parent 0000db1f86
commit d3d9c804e9
5 changed files with 25 additions and 6 deletions
+9 -2
View File
@@ -191,10 +191,14 @@ function item(body, opts) {
li.className = "choice";
li.append(picker);
}
const target = picker ?? li;
const first = picker ? [] : [body[0]];
const rest = body.slice(1);
if (rest.every((l) => !startsBlockLine(l)) && !rest.includes("")) {
li.append(...joinLines([...first, ...rest].map((l) => l.trim()), opts));
if (picker && rest.length > 0) {
target.append(h("br"));
}
target.append(...joinLines([...first, ...rest].map((l) => l.trim()), opts));
return li;
}
const head = first;
@@ -203,7 +207,10 @@ function item(body, opts) {
head.push(body[k].trim());
k++;
}
li.append(...joinLines(head, opts), ...blocks(body.slice(k), opts));
if (picker && head.length > 0) {
target.append(h("br"));
}
target.append(...joinLines(head, opts), ...blocks(body.slice(k), opts));
return li;
}
function startsBlockLine(line) {
+1 -1
View File
File diff suppressed because one or more lines are too long
+9 -2
View File
@@ -220,10 +220,14 @@ function item(body: string[], opts: Options): HTMLElement {
li.className = "choice";
li.append(picker);
}
const target = picker ?? li;
const first = picker ? [] : [body[0]!];
const rest = body.slice(1);
if (rest.every((l) => !startsBlockLine(l)) && !rest.includes("")) {
li.append(...joinLines([...first, ...rest].map((l) => l.trim()), opts));
if (picker && rest.length > 0) {
target.append(h("br"));
}
target.append(...joinLines([...first, ...rest].map((l) => l.trim()), opts));
return li;
}
const head: string[] = first;
@@ -232,7 +236,10 @@ function item(body: string[], opts: Options): HTMLElement {
head.push(body[k]!.trim());
k++;
}
li.append(...joinLines(head, opts), ...blocks(body.slice(k), opts));
if (picker && head.length > 0) {
target.append(h("br"));
}
target.append(...joinLines(head, opts), ...blocks(body.slice(k), opts));
return li;
}
+5
View File
@@ -1369,6 +1369,11 @@ pre.file-text .line::before {
cursor: pointer;
}
.pick > :last-child,
.option > :last-child {
margin-bottom: 0;
}
.pick:hover,
.pick:focus-visible {
border-color: var(--accent);