diff --git a/extensions/qqbot/src/engine/messaging/markdown-table-chunking.test.ts b/extensions/qqbot/src/engine/messaging/markdown-table-chunking.test.ts index 0a56bb33530..a516c635b91 100644 --- a/extensions/qqbot/src/engine/messaging/markdown-table-chunking.test.ts +++ b/extensions/qqbot/src/engine/messaging/markdown-table-chunking.test.ts @@ -46,6 +46,15 @@ describe("chunkQQBotMarkdownText", () => { ).toEqual([["| Id | Value |", "|---:|---|", "| 1 | alpha |", "| 2 | beta |"].join("\n")]); }); + it("confirms a table when the separator uses one or two dashes, not only three", () => { + // GFM delimiter cells need only one or more dashes; a sub-3-dash separator previously failed + // recognition, so the header and all rows but the last were silently dropped on send. + for (const separator of ["|--|--|", "|-|-|", "|:--|--:|"]) { + const text = ["| Id | Value |", separator, "| 1 | alpha |", "| 2 | beta |"].join("\n"); + expect(chunkQQBotMarkdownText(text, 200, baseChunker)).toEqual([text]); + } + }); + it("flushes a possible table header as text when the next block is not a separator", () => { const chunker = createQQBotMarkdownChunker((text) => [text]); diff --git a/extensions/qqbot/src/engine/messaging/markdown-table-chunking.ts b/extensions/qqbot/src/engine/messaging/markdown-table-chunking.ts index 343032415c2..0695f7c8e3a 100644 --- a/extensions/qqbot/src/engine/messaging/markdown-table-chunking.ts +++ b/extensions/qqbot/src/engine/messaging/markdown-table-chunking.ts @@ -433,7 +433,10 @@ function isTableSeparatorLine(line: string): boolean { return false; } const cells = splitTableCells(line); - return cells.length > 0 && cells.every((cell) => /^:?-{3,}:?$/.test(cell.trim())); + // GFM delimiter cells need only one or more hyphens (optionally colon-aligned), so accept "-+", + // not "-{3,}": a valid 1/2-dash separator (e.g. |--|--|) was not recognized here, leaving the + // header pending and silently overwritten by later rows so the table's header and rows vanished. + return cells.length > 0 && cells.every((cell) => /^:?-+:?$/.test(cell.trim())); } function splitTableCells(line: string): string[] {