diff options
author | Bibiko <bibiko@eva.mpg.de> | 2010-02-04 12:34:50 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2010-02-04 12:34:50 +0000 |
commit | 2c5453a01eae97bf03f16cfd088f2f069bb0594d (patch) | |
tree | 2f46278ea90be2b7e951af3f70ce9d41fe67e355 /Source | |
parent | 7b7e81cfdda087a27836cb056a7b7f1fbabe1d50 (diff) | |
download | sequelpro-2c5453a01eae97bf03f16cfd088f2f069bb0594d.tar.gz sequelpro-2c5453a01eae97bf03f16cfd088f2f069bb0594d.tar.bz2 sequelpro-2c5453a01eae97bf03f16cfd088f2f069bb0594d.zip |
• fixed undo behaviour of insertion of history/query favs
• improved text macro/query favs insertion logic
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMTextView.m | 13 | ||||
-rw-r--r-- | Source/CustomQuery.m | 9 |
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) |