fix infinite loop with tasks plugin

This commit is contained in:
Grol Grol 2025-08-08 13:06:19 +03:00
parent 235f1cb942
commit b685655e51

View file

@ -54,7 +54,9 @@ export class CheckboxLine extends AbstractLine {
private static getNewCheckboxLineFromTasksApi(api: any, checkboxLine: CheckboxLine, targetState: CheckboxState): CheckboxLine | null {
let line: CheckboxLine | null = checkboxLine;
const startChar = checkboxLine.checkChar;
const seenChars = new Set<string>();
seenChars.add(checkboxLine.checkChar);
while (true) {
const textLine = line.toResultText();
const newTextLine = api.executeToggleTaskDoneCommand(textLine, null);
@ -65,9 +67,11 @@ export class CheckboxLine extends AbstractLine {
if (newBox.checkboxState === targetState) {
return newBox;
}
if (newBox.checkChar === startChar){
if (seenChars.has(newBox.checkChar)) {
return null;
}
seenChars.add(newBox.checkChar);
line = newBox;
}
}