From 9ddba22bb253c7aa0a35b160ee4c743f45602626 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Wed, 8 Apr 2009 15:19:10 +0000 Subject: =?UTF-8?q?=E2=80=A2=20FIXED=20auto-uppercasing=20bug=20if=20SQL?= =?UTF-8?q?=20keyword=20is=20found=20at=20the=20absolute=20end=20of=20the?= =?UTF-8?q?=20textStorage=20-=20this=20fixes=20also=20auto-uppercasing=20f?= =?UTF-8?q?or=20runAll/Current/SelectionQueries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/CMTextView.m | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Source') 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 -- cgit v1.2.3