From 634d88d220a3471610cbb0df2e784c7c9257d73b Mon Sep 17 00:00:00 2001 From: Clem Date: Thu, 17 Aug 2023 19:32:52 +0200 Subject: [PATCH] refactoring ad3b03cb839717d98af3eb871ab7c35bf59f954c --- tabby-core/src/components/selectorModal.component.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tabby-core/src/components/selectorModal.component.ts b/tabby-core/src/components/selectorModal.component.ts index a0a25fb9..772adef2 100644 --- a/tabby-core/src/components/selectorModal.component.ts +++ b/tabby-core/src/components/selectorModal.component.ts @@ -33,11 +33,10 @@ export class SelectorModalComponent { this.close() } else if (this.filteredOptions.length > 0) { if (event.key === 'PageUp' || event.key === 'ArrowUp' && event.metaKey) { - this.selectedIndex -= Math.min(10, this.selectedIndex === 0 ? 1 : this.selectedIndex) + this.selectedIndex -= Math.min(10, Math.max(1, this.selectedIndex)) event.preventDefault() } else if (event.key === 'PageDown' || event.key === 'ArrowDown' && event.metaKey) { - const newI = this.filteredOptions.length - this.selectedIndex - 1 - this.selectedIndex += Math.min(10, newI === 0 ? 1 : newI) + this.selectedIndex += Math.min(10, Math.max(1, this.filteredOptions.length - this.selectedIndex - 1)) event.preventDefault() } else if (event.key === 'ArrowUp') { this.selectedIndex--