Skip to content

Commit e8d5fa0

Browse files
committed
Fixes for input methods:
1. Increase search / reset timer options in the UI up to 5 and 3s 2. Fix - reset the search timers when a the input method text is changed 3. Fix - make spacebar behave properly (insert character) when an input method is being used
1 parent c021dc7 commit e8d5fa0

File tree

3 files changed

+78
-53
lines changed

3 files changed

+78
-53
lines changed

Quicksilver/Code-QuickStepInterface/QSSearchObjectView.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ typedef NS_ENUM(NSUInteger, QSSearchMode) {
6565

6666
// whether or not the string in the underlying text editor should be 'sniffed' when editing (see QSObject_StringHandling.m - sniffString for more info)
6767
BOOL shouldSniff;
68+
BOOL hasMarkedTextState; // tracks input method composition state
6869
QSAction *alternateActionCounterpart;
6970

7071
@public

Quicksilver/Code-QuickStepInterface/QSSearchObjectView.m

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ - (void)awakeFromNib {
7575
preferredEdge = NSMaxXEdge;
7676
partialString = [[NSMutableString alloc] initWithCapacity:1];
7777
[partialString setString:@""];
78+
hasMarkedTextState = NO;
7879

7980
matchedString = nil;
8081

@@ -1089,10 +1090,12 @@ - (void)keyDown:(NSEvent *)theEvent {
10891090
return;
10901091

10911092
if ([eventCharactersIgnoringModifiers isEqualToString:@" "]) {
1092-
if ([theEvent type] == NSEventTypeKeyDown) {
1093+
if ([theEvent type] == NSEventTypeKeyDown && ![self hasMarkedText]) {
10931094
[self insertSpace:nil];
10941095
}
1095-
return;
1096+
if (![self hasMarkedText]) {
1097+
return;
1098+
}
10961099
}
10971100

10981101
// ***warning * have downshift move to indirect object
@@ -1662,10 +1665,31 @@ - (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange {
16621665
[self setMarkedText:aString selectedRange:selRange replacementRange:NSMakeRange(0, 0)];
16631666
}
16641667

1665-
- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange {}
1668+
- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange {
1669+
// Set marked text state for input method composition
1670+
hasMarkedTextState = (aString != nil && [aString length] > 0);
1671+
1672+
// Extend timers when input method is composing text
1673+
// This prevents the search from timing out while user is typing with input methods
1674+
1675+
// Extend search timer
1676+
if ([searchTimer isValid]) {
1677+
[searchTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:[[NSUserDefaults standardUserDefaults] floatForKey:kSearchDelay]]];
1678+
}
16661679

1667-
- (void)unmarkText {}
1668-
- (BOOL)hasMarkedText { return NO; }
1680+
// Extend reset timer
1681+
if ([resetTimer isValid]) {
1682+
CGFloat resetDelay = [[NSUserDefaults standardUserDefaults] floatForKey:kResetDelay];
1683+
if (resetDelay) {
1684+
[resetTimer setFireDate:[NSDate dateWithTimeIntervalSinceNow:resetDelay]];
1685+
}
1686+
}
1687+
}
1688+
1689+
- (void)unmarkText {
1690+
hasMarkedTextState = NO;
1691+
}
1692+
- (BOOL)hasMarkedText { return hasMarkedTextState; }
16691693
- (NSInteger)conversationIdentifier { return (long)self; }
16701694

16711695
- (NSAttributedString *)attributedSubstringFromRange:(NSRange)theRange {

0 commit comments

Comments
 (0)