From 46b8b95acd0df8c82996fd54266f58662db6a4cd Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 21 Jan 2011 09:45:30 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20issue=20for=20placeholder=20inserti?= =?UTF-8?q?on=20while=20completion=20of=20already=20backticked=20names=20a?= =?UTF-8?q?nd=20the=20final=20insertion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPNarrowDownCompletion.m | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/SPNarrowDownCompletion.m b/Source/SPNarrowDownCompletion.m index f86c66c5..d6272d5b 100644 --- a/Source/SPNarrowDownCompletion.m +++ b/Source/SPNarrowDownCompletion.m @@ -953,8 +953,10 @@ NSString* toInsert = [curMatch substringFromIndex:[originalFilterString length]]; theCharRange.length += [toInsert length] - currentAutocompleteLength; theParseRange.length += [toInsert length]; + [theView breakUndoCoalescing]; [theView insertText:[toInsert lowercaseString]]; + autocompletePlaceholderWasInserted = YES; // Restore the text selection location, and clearly mark the autosuggested text @@ -971,7 +973,11 @@ if (!autocompletePlaceholderWasInserted) return; if (useFastMethod) { - [theView setSelectedRange:theCharRange]; + if(backtickMode) { + NSRange r = NSMakeRange(theCharRange.location+1,theCharRange.length); + [theView setSelectedRange:r]; + } else + [theView setSelectedRange:theCharRange]; [theView insertText:originalFilterString]; } else { NSRange attributeResultRange = NSMakeRange(0, 0); @@ -1018,8 +1024,12 @@ NSRange r = [theView selectedRange]; if(r.length) [theView setSelectedRange:r]; - else - [theView setSelectedRange:theCharRange]; + else { + if(backtickMode) + [theView setSelectedRange:NSMakeRange(theCharRange.location, theCharRange.length+2)]; + else + [theView setSelectedRange:theCharRange]; + } [theView insertText:aString]; @@ -1055,7 +1065,6 @@ && [[selectedItem objectForKey:@"path"] length]) { NSString *path = [[[selectedItem objectForKey:@"path"] componentsSeparatedByString:SPUniqueSchemaDelimiter] componentsJoinedByPeriodAndBacktickQuotedAndIgnoreFirst]; - // Check if path's db name is the current selected db name NSRange r = [path rangeOfString:[currentDb backtickQuotedString] options:NSCaseInsensitiveSearch range:NSMakeRange(0, [[currentDb backtickQuotedString] length])]; theCharRange = theParseRange; @@ -1068,7 +1077,7 @@ } else { // Is completion string a schema name for current connection if([selectedItem objectForKey:@"isRef"]) { - backtickMode = 0; // suppress move the caret one step rightwards + // backtickMode = 0; // suppress move the caret one step rightwards [self insert_text:[candidateMatch backtickQuotedString]]; } else { [self insert_text:candidateMatch]; -- cgit v1.2.3