aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPNarrowDownCompletion.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPNarrowDownCompletion.m')
-rw-r--r--Source/SPNarrowDownCompletion.m6
1 files changed, 6 insertions, 0 deletions
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index fc2c8728..d83f78c5 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -956,12 +956,18 @@
// Insert common prefix automatically
if([[self filterString] length] < [commonPrefix length]) {
+ NSUInteger currentSelectionPosition = [theView selectedRange].location;
NSString* toInsert = [commonPrefix substringFromIndex:[[self filterString] length]];
[mutablePrefix appendString:toInsert];
theCharRange.length += [toInsert length];
theParseRange.length += [toInsert length];
[theView insertText:[toInsert lowercaseString]];
commonPrefixWasInsertedByAutoComplete = YES;
+
+ // Restore the text selection location, and clearly mark the autosuggested text
+ [theView setSelectedRange:NSMakeRange(currentSelectionPosition, 0)];
+ NSMutableAttributedStringAddAttributeValueRange([theView textStorage], NSForegroundColorAttributeName, [[theView otherTextColor] colorWithAlphaComponent:0.3], NSMakeRange(currentSelectionPosition, [toInsert length]));
+
[self checkSpaceForAllowedCharacter];
}
}