aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-04-08 15:32:15 +0000
committerBibiko <bibiko@eva.mpg.de>2009-04-08 15:32:15 +0000
commit83ac00d433f242c626bcba8da734446d886c1cc4 (patch)
treeb270e1d6166b85361c8df128a93d3f3f88214c5b /Source/CMTextView.m
parent9ddba22bb253c7aa0a35b160ee4c743f45602626 (diff)
downloadsequelpro-83ac00d433f242c626bcba8da734446d886c1cc4.tar.gz
sequelpro-83ac00d433f242c626bcba8da734446d886c1cc4.tar.bz2
sequelpro-83ac00d433f242c626bcba8da734446d886c1cc4.zip
• FIXED if deleteBackward: avoid auto-uppercasing if resulting word would be a SQL keyword
- e.g. type inta and then press deleteBackward:
Diffstat (limited to 'Source/CMTextView.m')
-rw-r--r--Source/CMTextView.m12
1 files changed, 9 insertions, 3 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index c41206d0..f1af835e 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -171,6 +171,8 @@ YY_BUFFER_STATE yy_scan_string (const char *);
// Only process for character autopairing if autopairing is enabled and a single character is being added.
if (autopairEnabled && characters && [characters length] == 1) {
+ delBackwardsWasPressed = NO;
+
NSString *matchingCharacter = nil;
BOOL processAutopair = NO, skipTypedLinkedCharacter = NO;
NSRange currentRange;
@@ -304,7 +306,10 @@ YY_BUFFER_STATE yy_scan_string (const char *);
NSRange currentRange = [self selectedRange];
if (currentRange.length == 0 && currentRange.location > 0 && [self areAdjacentCharsLinked])
[self setSelectedRange:NSMakeRange(currentRange.location - 1,2)];
-
+
+ // Avoid auto-uppercasing if resulting word would be a SQL keyword;
+ // e.g. type inta| and deleteBackward:
+ delBackwardsWasPressed = YES;
[super deleteBackward:sender];
}
@@ -901,6 +906,7 @@ SYNTAX HIGHLIGHTING!
autopairEnabled = YES;
autoindentIgnoresEnter = NO;
autouppercaseKeywordsEnabled = YES;
+ delBackwardsWasPressed = NO;
}
- (void)textStorageDidProcessEditing:(NSNotification *)notification
@@ -982,7 +988,7 @@ SYNTAX HIGHLIGHTING!
// If the current token is marked as SQL keyword, uppercase it if required.
unsigned long tokenEnd = tokenRange.location+tokenRange.length-1; // Check the end of the token
- if (autouppercaseKeywordsEnabled
+ if (autouppercaseKeywordsEnabled && !delBackwardsWasPressed
&& [[self textStorage] attribute:kSQLkeyword atIndex:tokenEnd effectiveRange:nil])
// 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
@@ -1002,7 +1008,7 @@ SYNTAX HIGHLIGHTING!
[self replaceCharactersInRange:tokenRange withString:[curTokenString uppercaseString]];
}
}
-
+
[textStore addAttribute: NSForegroundColorAttributeName
value: tokenColor
range: tokenRange ];