From 83ac00d433f242c626bcba8da734446d886c1cc4 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 8 Apr 2009 15:32:15 +0000 Subject: =?UTF-8?q?=E2=80=A2=20FIXED=20if=20deleteBackward:=20avoid=20auto?= =?UTF-8?q?-uppercasing=20if=20resulting=20word=20would=20be=20a=20SQL=20k?= =?UTF-8?q?eyword=20-=20e.g.=20type=20inta=20and=20then=20press=20deleteBa?= =?UTF-8?q?ckward:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMTextView.h | 1 + Source/CMTextView.m | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'Source') 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 ]; -- cgit v1.2.3