From ebb795da893b463ef76f3c66f3696885351bbcd9 Mon Sep 17 00:00:00 2001 From: luckman212 <1992842+luckman212@users.noreply.github.com> Date: Sat, 22 Jun 2024 17:57:13 -0400 Subject: [PATCH] update --- src/block_utils.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/block_utils.ts b/src/block_utils.ts index eba094c..a8f5061 100644 --- a/src/block_utils.ts +++ b/src/block_utils.ts @@ -20,10 +20,8 @@ export abstract class BlockUtils { console.log('error reading FileCache (empty file?)'); return; } - let currentBlock: SectionCache | ListItemCache = (() => { - const i = sections.findIndex(section => section.position.start.line > cursor.line); - return i > 0 ? sections[i - 1] : sections[sections.length - 1]; - })(); + const foundSectionIndex = sections.findIndex(section => section.position.start.line > cursor.line); + let currentBlock: SectionCache | ListItemCache = foundSectionIndex > 0 ? sections[foundSectionIndex - 1] : sections[sections.length - 1]; if (currentBlock?.type == "list") { currentBlock = fileCache.listItems?.find(section => section.position.start.line <= cursor.line &&