aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-08-27 20:01:21 +0000
committerBibiko <bibiko@eva.mpg.de>2009-08-27 20:01:21 +0000
commit0a7642665ea627738ac8a9b858c3ac45c5c0b941 (patch)
treea88a322cc6075e8e046f0702dcccfcb913261fbc /Source/CMTextView.m
parenta272f4a4cd8084d07add562bc60dec72c9b7b6f0 (diff)
downloadsequelpro-0a7642665ea627738ac8a9b858c3ac45c5c0b941.tar.gz
sequelpro-0a7642665ea627738ac8a9b858c3ac45c5c0b941.tar.bz2
sequelpro-0a7642665ea627738ac8a9b858c3ac45c5c0b941.zip
• fixed bug while uppercasing keywords
- inserting a char within an already marked keyword doesn't end up in inserting a uppercase char if resulting word won't be a new keyword
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m19
1 files changed, 13 insertions, 6 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 042a76fa..5afc75b4 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -2108,8 +2108,13 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
yyuoffset = textRange.location; yyuleng = 0;
yy_switch_to_buffer(yy_scan_string(NSStringUTF8String([selfstr substringWithRange:textRange])));
+ // NO if lexer doesn't find a token to suppress auto-uppercasing
+ // and continue earlier.
+ BOOL allowToCheckForUpperCase;
+
// now loop through all the tokens
while (token=yylex()){
+ allowToCheckForUpperCase = YES;
switch (token) {
case SPT_SINGLE_QUOTED_TEXT:
case SPT_DOUBLE_QUOTED_TEXT:
@@ -2131,25 +2136,25 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
tokenColor = variableColor;
break;
case SPT_WHITESPACE:
- tokenColor = nil;
+ continue;
break;
default:
tokenColor = textColor;
+ allowToCheckForUpperCase = NO;
}
- if (!tokenColor) continue;
-
tokenRange = NSMakeRange(yyuoffset, yyuleng);
// make sure that tokenRange is valid (and therefore within textRange)
// otherwise a bug in the lex code could cause the the TextView to crash
- tokenRange = NSIntersectionRange(tokenRange, textRange);
- if (!tokenRange.length) continue;
+ // NOTE Disabled for testing purposes for speed it up
+ // tokenRange = NSIntersectionRange(tokenRange, textRange);
+ // if (!tokenRange.length) continue;
// If the current token is marked as SQL keyword, uppercase it if required.
tokenEnd = tokenRange.location+tokenRange.length-1;
// Check the end of the token
- if (autouppercaseKeywords && !delBackwardsWasPressed
+ if (allowToCheckForUpperCase && autouppercaseKeywords && !delBackwardsWasPressed
&& [[textStore attribute:kSQLkeyword atIndex:tokenEnd effectiveRange:nil] isEqualToString:kValue])
// 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
@@ -2174,6 +2179,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
NSMutableAttributedStringAddAttributeValueRange(textStore, NSForegroundColorAttributeName, tokenColor, tokenRange);
+ if(!allowToCheckForUpperCase) continue;
+
// Add an attribute to be used in the auto-pairing (keyDown:)
// to disable auto-pairing if caret is inside of any token found by lex.
// For discussion: maybe change it later (only for quotes not keywords?)