aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPNarrowDownCompletion.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPNarrowDownCompletion.m')
-rw-r--r--Source/SPNarrowDownCompletion.m4
1 files changed, 4 insertions, 0 deletions
diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m
index ac29fc08..cfdd7605 100644
--- a/Source/SPNarrowDownCompletion.m
+++ b/Source/SPNarrowDownCompletion.m
@@ -759,6 +759,10 @@
- (void)insert_text:(NSString* )aString
{
+ // Ensure that theCharRange is valid
+ if(NSMaxRange(theCharRange) > [[theView string] length])
+ theCharRange = NSIntersectionRange(NSMakeRange(0,[[theView string] length]), theCharRange);
+
NSRange r = [theView selectedRange];
if(r.length)
[theView setSelectedRange:r];