aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m13
-rw-r--r--Source/CustomQuery.m9
2 files changed, 17 insertions, 5 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?
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 75bbb894..a891f35e 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -211,11 +211,14 @@
if([[NSApp currentEvent] modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask))
replaceContent = !replaceContent;
- if(replaceContent)
+ if(replaceContent) {
[textView setSelectedRange:NSMakeRange(0,[[textView string] length])];
+ [textView breakUndoCoalescing];
+ [textView insertText:@""];
+ }
// The actual query strings have been already stored as tooltip
- [textView insertFavoriteAsSnippet:[[queryFavoritesButton selectedItem] toolTip] atRange:[textView selectedRange]];
+ [textView insertFavoriteAsSnippet:[[queryFavoritesButton selectedItem] toolTip] atRange:NSMakeRange([textView selectedRange].location, 0)];
}
}
@@ -231,7 +234,7 @@
if ([queryHistoryButton indexOfSelectedItem] > 6) {
BOOL replaceContent = [prefs boolForKey:SPQueryHistoryReplacesContent];
-
+ [textView breakUndoCoalescing];
if([[NSApp currentEvent] modifierFlags] & (NSShiftKeyMask|NSControlKeyMask|NSAlternateKeyMask|NSCommandKeyMask))
replaceContent = !replaceContent;
if(replaceContent)