aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-29 14:22:46 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-29 14:22:46 +0000
commit7591371032bbb7956b71ee5d70c0c3139872e3dd (patch)
tree9367852ee7b90852eb23f753bc474c6c9e2763e9 /Source
parenta0f3e12600411888242efd76959a124de74ee630 (diff)
downloadsequelpro-7591371032bbb7956b71ee5d70c0c3139872e3dd.tar.gz
sequelpro-7591371032bbb7956b71ee5d70c0c3139872e3dd.tar.bz2
sequelpro-7591371032bbb7956b71ee5d70c0c3139872e3dd.zip
• further tiny improvements to avoid exceptional cases while highlighting the erroneous query
- added check for near message length - make an intersection with the buffer range before selecting • text macro - each selection of a snippet breaks the undo buffer - note: undo behaviour while text macro session is active needs to be solved ⇢ work in progress
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m3
-rw-r--r--Source/CustomQuery.m21
2 files changed, 20 insertions, 4 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 886df5a6..2bc01fcd 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -922,6 +922,9 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
&& currentSnippetIndex <= snippetControlMax
)
{
+
+ [self breakUndoCoalescing];
+
// Place the caret at the end of the query favorite snippet
// and finish snippet editing
if(currentSnippetIndex == snippetControlMax) {
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 2ce831f4..9600d929 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -701,21 +701,33 @@
{
// Get the line number
NSUInteger errorAtLine = [[errors substringWithRange:errorLineNumberRange] integerValue];
- NSUInteger lineOffset = [textView getLineNumberForCharacterIndex:queryTextViewStartPosition] - 1;
+ NSUInteger lineOffset = [textView getLineNumberForCharacterIndex:[self queryTextRangeForQuery:firstErrorOccuredInQuery startPosition:queryStartPosition].location] - 1;
[textView selectLineNumber:errorAtLine+lineOffset ignoreLeadingNewLines:YES];
// Check for near message
NSRange errorNearMessageRange = [errors rangeOfRegex:@"[( ]'(.+)'[ -]" options:(RKLMultiline|RKLDotAll) inRange:NSMakeRange(0, [errors length]) capture:1L error:nil];
- if(errorNearMessageRange.length) // if a "near message" was found
+ if(errorNearMessageRange.length > 2) // if a "near message" was found
{
+ NSUInteger bufferLength = [[textView string] length];
+
+ NSRange bufferRange = NSMakeRange(0, bufferLength);
+
// Build the range to search for nearMessage (beginning from queryStartPosition to try to avoid mismatching)
- NSRange theRange = NSMakeRange(queryStartPosition, [[textView string] length]-queryStartPosition);
+ NSRange theRange = NSMakeRange(queryStartPosition, bufferLength-queryStartPosition);
+ theRange = NSIntersectionRange(bufferRange, theRange);
+
// Get the range in textView of the near message
NSRange textNearMessageRange = [[[textView string] substringWithRange:theRange] rangeOfString:[errors substringWithRange:errorNearMessageRange] options:NSLiteralSearch];
+
// Correct the near message range relative to queryStartPosition
textNearMessageRange = NSMakeRange(textNearMessageRange.location+queryStartPosition, textNearMessageRange.length);
+ textNearMessageRange = NSIntersectionRange(bufferRange, textNearMessageRange);
+
// Select the near message and scroll to it
- [textView setSelectedRange:textNearMessageRange];
+ if(textNearMessageRange.length > 0) {
+ [textView setSelectedRange:textNearMessageRange];
+ [textView scrollRangeToVisible:textNearMessageRange];
+ }
}
} else { // Select first erroneous query entirely
@@ -729,6 +741,7 @@
} else {
// select the query for which the first error was detected
queryRange = [self queryTextRangeForQuery:firstErrorOccuredInQuery startPosition:queryStartPosition];
+ queryRange = NSIntersectionRange(NSMakeRange(0, [[textView string] length]), queryRange);
[textView setSelectedRange:queryRange];
[textView scrollRangeToVisible:queryRange];
}