From 145b6447b948240beabd09262f660959920ca0ac Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Wed, 28 Dec 2022 16:08:35 +0100 Subject: [PATCH] debounce typing in search field - fixes #7579 --- .../src/components/searchPanel.component.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tabby-terminal/src/components/searchPanel.component.ts b/tabby-terminal/src/components/searchPanel.component.ts index 606206f8..b7b06552 100644 --- a/tabby-terminal/src/components/searchPanel.component.ts +++ b/tabby-terminal/src/components/searchPanel.component.ts @@ -1,4 +1,5 @@ import { Component, Input, Output, EventEmitter } from '@angular/core' +import { Subject, debounceTime } from 'rxjs' import { Frontend, SearchOptions, SearchState } from '../frontends/frontend' import { ConfigService, NotificationsService, TranslateService } from 'tabby-core' @@ -18,6 +19,8 @@ export class SearchPanelComponent { @Output() close = new EventEmitter() + private queryChanged = new Subject() + icons = { 'case': require('../icons/case.svg'), regexp: require('../icons/regexp.svg'), @@ -31,11 +34,15 @@ export class SearchPanelComponent { private notifications: NotificationsService, private translate: TranslateService, public config: ConfigService, - ) { } + ) { + this.queryChanged.pipe(debounceTime(250)).subscribe(() => { + this.findPrevious(true) + }) + } onQueryChange (): void { this.state = { resultCount: 0 } - this.findPrevious(true) + this.queryChanged.next(this.query) } findNext (incremental = false): void { @@ -65,4 +72,8 @@ export class SearchPanelComponent { this.config.save() } + + ngOnDestroy () { + this.queryChanged.complete() + } }