From: Scott Worley Date: Fri, 20 Oct 2023 19:57:33 +0000 (-0700) Subject: j/k should select something if there's no selected task X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/55c0520e11d12258f0913f11043fc402723339f8?hp=c548954c7a413e97cd4d57b79a9ea33d2b26114f j/k should select something if there's no selected task --- diff --git a/vopamoi.ts b/vopamoi.ts index 0389a04..30efb1b 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -446,6 +446,7 @@ function BrowserUI() { var target = document.activeElement; if (!target) return null; if (target.classList.contains("tag")) target = target.parentElement!; + if (!target.classList.contains("task")) return null; return target as HTMLElement; }, @@ -525,7 +526,11 @@ function BrowserUI() { }, moveCursorVertically: function (offset: number): boolean { - const active = this.currentTask(); + let active = this.currentTask(); + if (!active) { + this.firstVisibleTask()?.focus(); + active = this.currentTask(); + } if (!active) return false; const dest = this.visibleTaskAtOffset(active, offset); if (dest !== active && dest instanceof HTMLElement) {