修复了在切换列表类型时重置计数器的问题,确保任务列表项的编号能够正确延续。

This commit is contained in:
naive231 2024-11-19 09:16:23 +08:00
parent 6a3bcb1cbc
commit 146b26f8e4
1 changed files with 0 additions and 10 deletions

10
main.ts
View File

@ -111,20 +111,10 @@ function processLineBlock(source: string): string {
}
if (isListItem) {
// Handle list type change
if (listType !== previousListType && indentLevel === 0) {
// Reset counters when switching list types at top level
listCounters = [];
prevIndentLevel = 0;
}
previousListType = listType;
// Handle indent level
if (indentLevel > prevIndentLevel) {
// Entering new sublist level
listCounters.push(0);
} else if (indentLevel < prevIndentLevel) {
// Exiting to higher level(s)
while (listCounters.length > indentLevel) {
listCounters.pop();
}