Skip to content

Commit

Permalink
Revert "Remove 'Wait before searching' option"
Browse files Browse the repository at this point in the history
This reverts commit 991f037.
  • Loading branch information
pjrobertson committed May 27, 2022
1 parent 84be3f5 commit 39c50f2
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 52 deletions.
3 changes: 2 additions & 1 deletion Quicksilver/Code-QuickStepCore/QSPreferenceKeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Following lines are no longer used in this project.
#define kDelayQuit @"Delay Before Quitting"

#define kResetDelay @"Reset Delay"
#define kSearchDelay @"Search Delay"

#define kActivationHotKey @"ActivationHotKey"
#define kHideDockIcon @"Hide Dock Icon"
Expand Down Expand Up @@ -76,4 +77,4 @@ Following lines are no longer used in this project.
#define kQSShowTaskViewerAutomatically @"QSShowTaskViewerAutomatically"

// A boolean indicating whether the task viewer resizes automatically
#define kQSResizeTaskViewerAutomatically @"QSResizeTaskViewerAutomatically"
#define kQSResizeTaskViewerAutomatically @"QSResizeTaskViewerAutomatically"
1 change: 1 addition & 0 deletions Quicksilver/Code-QuickStepInterface/QSSearchObjectView.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ typedef NS_ENUM(NSUInteger, QSSearchMode) {
BOOL validSearch;

NSTimer *resetTimer;
NSTimer *searchTimer;
NSTimer *resultTimer;

NSTimeInterval lastTime;
Expand Down
31 changes: 27 additions & 4 deletions Quicksilver/Code-QuickStepInterface/QSSearchObjectView.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ + (void)initialize {
- (void)awakeFromNib {
[super awakeFromNib];
resetTimer = nil;
searchTimer = nil;
resultTimer = nil;
preferredEdge = NSMaxXEdge;
partialString = [[NSMutableString alloc] initWithCapacity:1];
Expand Down Expand Up @@ -874,6 +875,13 @@ - (void)performSearchFor:(NSString *)string from:(id)sender {
[resultController.searchStringField setTextColor:[NSColor redColor]];
}

// Extend Timers
if ([searchTimer isValid]) {
// NSLog(@"extend");
[searchTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:[[NSUserDefaults standardUserDefaults] floatForKey:kSearchDelay]]];

}

if ([resetTimer isValid]) {
CGFloat resetDelay = [[NSUserDefaults standardUserDefaults] floatForKey:kResetDelay];
if (resetDelay) [resetTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:resetDelay]];
Expand All @@ -890,8 +898,19 @@ - (void)resetString {

- (void)partialStringChanged {
[self setSearchString:[partialString copy]];

[self performSearch:nil];

double searchDelay = [[NSUserDefaults standardUserDefaults] floatForKey:kSearchDelay];

// only wait for 'search delay' if we're searching all objects
if ([self searchMode] != SearchFilterAll) {
[searchTimer invalidate];
[self performSearch:nil];
} else {
if (![searchTimer isValid]) {
searchTimer = [NSTimer scheduledTimerWithTimeInterval:searchDelay target:self selector:@selector(performSearch:) userInfo:nil repeats:NO];
}
[searchTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:searchDelay]];
}

if (validSearch) {
NSColor *color = [[NSUserDefaults standardUserDefaults] colorForKey:@"QSAppearance2T"];
Expand All @@ -912,8 +931,11 @@ - (void)partialStringChanged {

- (void)executeCommand:(id)sender {
[resultTimer invalidate];
[self performSearchFor:partialString from:self];
[self display];
if ([searchTimer isValid]) {
[searchTimer invalidate];
[self performSearchFor:partialString from:self];
[self display];
}
[resetTimer fire];
[[self controller] executeCommand:self];
}
Expand Down Expand Up @@ -1455,6 +1477,7 @@ - (void)deleteBackward:(id)sender {
[self clearTextView];
return;
}
[searchTimer invalidate];
// reset the search array
[self setSearchArray:nil];
if (!partialString || partialString.length <= 1) {
Expand Down
Loading

0 comments on commit 39c50f2

Please sign in to comment.