aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m13
1 files changed, 11 insertions, 2 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index d9ba59f4..33d56544 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -1112,6 +1112,11 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
- (void)insertFavoriteAsSnippet:(NSString*)theSnippet atRange:(NSRange)targetRange
{
+ if(snippetControlCounter > -1) {
+ NSBeep();
+ return;
+ }
+
NSInteger i;
// reset snippet array
@@ -1127,7 +1132,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
@try{
NSString *re = @"(?<!\\\\)\\$\\{(1?\\d):([^\\{\\}]*)\\}";
- targetRange = NSIntersectionRange(NSMakeRange(0,[[self string] length]), targetRange);
+ if(targetRange.length)
+ targetRange = NSIntersectionRange(NSMakeRange(0,[[self string] length]), targetRange);
[snip setString:theSnippet];
if(snip == nil || ![snip length]) return;
@@ -1222,10 +1228,13 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[self breakUndoCoalescing];
// Insert favorite query as snippet if any
- [self setSelectedRange:targetRange];
+ // if(targetRange.length)
+ [self setSelectedRange:targetRange];
// Suppress snippet range calculation in [self textStorageDidProcessEditing] while initial insertion
snippetWasJustInserted = YES;
+
+ [self breakUndoCoalescing];
[self insertText:snip];
// Any snippets defined?