Add debounce to status bar search and filter components
Problem
When typing in the status bar search or filter components, the search/filter operations trigger immediately on every keystroke. This causes a flickering/blinking effect as the results update in real-time, which creates visual noise and can be distracting.
Solution
Added a 300ms debounce delay to both components:
- MiniFilterViewController (Swift): Debounces filter query changes
- iTermMiniSearchFieldViewController (Objective-C): Debounces search query changes
Changes
- Added
debounceTimerproperty to both view controllers - Modified
controlTextDidChangemethods to invalidate previous timers and schedule new ones - Search/filter operations now wait 300ms after the last keystroke before executing
Benefits
- Eliminates flickering/blinking effect while typing
- Reduces unnecessary search/filter operations
- Improves overall user experience and performance
- Makes the UI feel more polished and responsive
Testing
Manually tested both search and filter components by typing rapidly and verifying that:
- Results only update after stopping typing for 300ms
- No flickering occurs during typing
- Functionality remains intact
Search is already debounced using the algorithm in iTermFindDriver.m (see line 291). I think it makes sense to also debounce Filter, but it should use the same algorithm. Probably the debouncing algorithm should be factored out into its own class which can then be shared by iTermFindDriver and AsyncFilter.
Good catch! This was an unintentional behavior change. The original code had a !self.viewController.view.isHidden check in startDelay that was lost during the refactoring.
I've restored this check in the debouncer callback to preserve the original behavior - searches will only execute when the view is visible.
Fixed in ca0da73