From f36b20d6c8aff57f2582ffc800d20f03ab0bb44c Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 2 Mar 2022 15:54:00 -0800 Subject: [PATCH] 'l' goes to first *visible* subtask I.e., it does something even if the first subtask is hidden because it's complete or something. --- vopamoi.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vopamoi.ts b/vopamoi.ts index 5f759d0..8e72809 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -378,8 +378,9 @@ function BrowserUI() { return target as HTMLElement; }, - firstVisibleTask: function () { - for (const task of document.getElementsByClassName("task")) { + firstVisibleTask: function (root: Element | null = null) { + if (root === null) root = document.body; + for (const task of root.getElementsByClassName("task")) { const state = task.getAttribute("data-state"); if ( task instanceof HTMLElement && @@ -447,7 +448,9 @@ function BrowserUI() { }, moveCursorRight: function () { - (this.currentTask()?.getElementsByClassName("task")[0] as HTMLElement)?.focus(); + const active = this.currentTask(); + if (!active) return false; + (this.firstVisibleTask(active) as HTMLElement | null)?.focus(); }, moveCursorVertically: function (offset: number): boolean { -- 2.44.1