Merge pull request #4379 from Perlence/fix-tui-todo-checkboxes

fix(tui): render the checkboxes in the to-do list items
This commit is contained in:
Mario Zechner
2026-05-13 00:17:25 +02:00
committed by GitHub
2 changed files with 12 additions and 2 deletions

View File

@@ -556,8 +556,10 @@ export class Markdown implements Component {
for (let i = 0; i < token.items.length; i++) { for (let i = 0; i < token.items.length; i++) {
const item = token.items[i]; const item = token.items[i];
const bullet = token.ordered ? `${startNumber + i}. ` : "- "; const bullet = token.ordered ? `${startNumber + i}. ` : "- ";
const firstPrefix = indent + this.theme.listBullet(bullet); const taskMarker = item.task ? `[${item.checked ? "x" : " "}] ` : "";
const continuationPrefix = indent + " ".repeat(visibleWidth(bullet)); const marker = bullet + taskMarker;
const firstPrefix = indent + this.theme.listBullet(marker);
const continuationPrefix = indent + " ".repeat(visibleWidth(marker));
const itemWidth = Math.max(1, width - visibleWidth(firstPrefix)); const itemWidth = Math.max(1, width - visibleWidth(firstPrefix));
let renderedAnyLine = false; let renderedAnyLine = false;

View File

@@ -124,6 +124,14 @@ describe("Markdown component", () => {
assert.ok(plainLines.some((line) => line.includes("2. Second ordered"))); assert.ok(plainLines.some((line) => line.includes("2. Second ordered")));
}); });
it("should render task list markers", () => {
const markdown = new Markdown("- [ ] beep\n- [x] boop", 0, 0, defaultMarkdownTheme);
const lines = markdown.render(80).map((line) => stripAnsi(line).trimEnd());
assert.deepStrictEqual(lines, ["- [ ] beep", "- [x] boop"]);
});
it("should maintain numbering when code blocks are not indented (LLM output)", () => { it("should maintain numbering when code blocks are not indented (LLM output)", () => {
// When code blocks aren't indented, marked parses each item as a separate list. // When code blocks aren't indented, marked parses each item as a separate list.
// We use token.start to preserve the original numbering. // We use token.start to preserve the original numbering.