aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-04-07 13:05:09 +0000
committerBibiko <bibiko@eva.mpg.de>2009-04-07 13:05:09 +0000
commit7baf6b3c55d8a697bee72b846596ff371dbea8ac (patch)
tree76863870e7ae981958836e5e1d395b67ca75815c /Source/CMTextView.m
parent8a8d39240ed1486c2fb4669f5f5340936c0ac391 (diff)
downloadsequelpro-7baf6b3c55d8a697bee72b846596ff371dbea8ac.tar.gz
sequelpro-7baf6b3c55d8a697bee72b846596ff371dbea8ac.tar.bz2
sequelpro-7baf6b3c55d8a697bee72b846596ff371dbea8ac.zip
• improved auto-uppercasing for: pasting queries from favourites & history and before performQueries
• improved undo behaviour of auto-uppercasing • added undo behaviour for pasting queries from favourites & history
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m18
1 files changed, 11 insertions, 7 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 0493f0c8..e8bb59ba 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -976,14 +976,18 @@ SYNTAX HIGHLIGHTING!
unsigned long tokenEnd = tokenRange.location+tokenRange.length-1; // Check the end of the token
if (autouppercaseKeywordsEnabled
&& [[self textStorage] attribute:kSQLkeyword atIndex:tokenEnd effectiveRange:nil])
- // check if next char is not a kSQLkeyword; if so then upper case keyword
+ // check if next char is not a kSQLkeyword; if so then upper case keyword if not already done
// @try catch() for catching valid index esp. after deleteBackward:
- @try {
- if(![[self textStorage] attribute:kSQLkeyword atIndex:tokenEnd+1 effectiveRange:nil])
- // Register it for undo
- // [self shouldChangeTextInRange:tokenRange replacementString:[[[self string] substringWithRange:tokenRange] uppercaseString]];
- // NOTE: If one does this registering it ends up in single-character-undo
- [self replaceCharactersInRange:tokenRange withString:[[[self string] substringWithRange:tokenRange] uppercaseString]];
+ @try
+ {
+ NSString* curTokenString = [[self string] substringWithRange:tokenRange];
+ if(![[self textStorage] attribute:kSQLkeyword atIndex:tokenEnd+1 effectiveRange:nil] &&
+ ![[curTokenString uppercaseString] isEqualToString:curTokenString])
+ {
+ // Register it for undo works only partly for now, at least the uppercased keyword will be selected
+ [self shouldChangeTextInRange:tokenRange replacementString:[curTokenString uppercaseString]];
+ [self replaceCharactersInRange:tokenRange withString:[curTokenString uppercaseString]];
+ }
} @catch(id ae) { }
[textStore addAttribute: NSForegroundColorAttributeName