aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-04-08 15:19:10 +0000
committerBibiko <bibiko@eva.mpg.de>2009-04-08 15:19:10 +0000
commit9ddba22bb253c7aa0a35b160ee4c743f45602626 (patch)
tree57814300b4e1c27f71d677add4a6e4397b79c0f7
parent91ff45d2c35bf11c1920d8b9f8b1450886ba2c5a (diff)
downloadsequelpro-9ddba22bb253c7aa0a35b160ee4c743f45602626.tar.gz
sequelpro-9ddba22bb253c7aa0a35b160ee4c743f45602626.tar.bz2
sequelpro-9ddba22bb253c7aa0a35b160ee4c743f45602626.zip
• FIXED auto-uppercasing bug if SQL keyword is found at the absolute end of the textStorage
- this fixes also auto-uppercasing for runAll/Current/SelectionQueries
-rw-r--r--Source/CMTextView.m15
1 files changed, 10 insertions, 5 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 336d3669..c41206d0 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -984,19 +984,24 @@ 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 if not already done
+ // check if next char is not a kSQLkeyword or current kSQLkeyword is at the end;
+ // if so then upper case keyword if not already done
// @try catch() for catching valid index esp. after deleteBackward:
- @try
{
NSString* curTokenString = [[self string] substringWithRange:tokenRange];
- if(![[self textStorage] attribute:kSQLkeyword atIndex:tokenEnd+1 effectiveRange:nil] &&
- ![[curTokenString uppercaseString] isEqualToString:curTokenString])
+ BOOL doIt = NO;
+ @try
+ {
+ doIt = ![[self textStorage] attribute:kSQLkeyword atIndex:tokenEnd+1 effectiveRange:nil];
+ } @catch(id ae) { doIt = YES; }
+
+ if(doIt && ![[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
value: tokenColor