aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.h1
-rw-r--r--Source/CMTextView.m12
2 files changed, 10 insertions, 3 deletions
diff --git a/Source/CMTextView.h b/Source/CMTextView.h
index cec4c67b..b9787dfc 100644
--- a/Source/CMTextView.h
+++ b/Source/CMTextView.h
@@ -28,6 +28,7 @@
BOOL autopairEnabled;
BOOL autoindentIgnoresEnter;
BOOL autouppercaseKeywordsEnabled;
+ BOOL delBackwardsWasPressed;
}
- (BOOL) isNextCharMarkedBy:(id)attribute;
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 ];