From 890022a6a462a2e7792379e316fa3866e737ff5c Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 12 Oct 2010 19:06:16 +0000 Subject: =?UTF-8?q?=E2=80=A2=20fixed=20cursor=20position=20correction=20fo?= =?UTF-8?q?r=20autoHelp=20-=20should=20fix=20among=20other=20issues=20i862?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTextView.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Source') diff --git a/Source/SPTextView.m b/Source/SPTextView.m index 84322397..32f97c15 100644 --- a/Source/SPTextView.m +++ b/Source/SPTextView.m @@ -2484,7 +2484,7 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) - (void)autoHelp { - if(![prefs boolForKey:SPCustomQueryUpdateAutoHelp]) return; + if(![prefs boolForKey:SPCustomQueryUpdateAutoHelp] || ![[self string] length]) return; // If selection show Help for it if([self selectedRange].length) @@ -2494,8 +2494,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } // Otherwise show Help if caret is not inside quotes NSUInteger cursorPosition = [self selectedRange].location; - if (cursorPosition >= [[self string] length]) cursorPosition--; - if(cursorPosition >= 0 && ![(NSString*)NSMutableAttributedStringAttributeAtIndex([self textStorage], kQuote, cursorPosition, nil) length]) + // If cursor at the end go one char leftwards + if (cursorPosition > 0 && cursorPosition >= [[self string] length]) cursorPosition--; + if (cursorPosition < [[self string] length] && ![(NSString*)NSMutableAttributedStringAttributeAtIndex([self textStorage], kQuote, cursorPosition, nil) length]) [customQueryInstance performSelector:@selector(showAutoHelpForCurrentWord:) withObject:self afterDelay:0.1]; } -- cgit v1.2.3