From d58f8b4ba1d873abb0fc8dc4c2cec64a33b55ab8 Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 29 Sep 2022 18:09:35 +0200 Subject: [PATCH] chore: break earlier if index === 0 --- src/helpers/parseSubtasksViaIndention.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/helpers/parseSubtasksViaIndention.ts b/src/helpers/parseSubtasksViaIndention.ts index e2900b098..5c9589b78 100644 --- a/src/helpers/parseSubtasksViaIndention.ts +++ b/src/helpers/parseSubtasksViaIndention.ts @@ -20,10 +20,14 @@ export function parseSubtasksViaIndention(taskTitles: string): TaskWithParent[] parent: null, } + if (index === 0) { + return task + } + const matched = spaceRegex.exec(title) const matchedSpaces = matched ? matched[0].length : 0 - if (matchedSpaces > 0 && index > 0) { + if (matchedSpaces > 0) { // Go up the tree to find the first task with less indention than the current one let pi = 1 let parentSpaces = 0