aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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