aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.h7
-rw-r--r--Source/CustomQuery.m18
2 files changed, 18 insertions, 7 deletions
diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h
index 374cfc0d..32d5be19 100644
--- a/Source/CustomQuery.h
+++ b/Source/CustomQuery.h
@@ -116,9 +116,9 @@
NSString *mySQLversion;
NSTableColumn *sortColumn;
- int queryStartPosition;
+ NSUInteger queryStartPosition;
- int helpTarget;
+ NSUInteger helpTarget;
WebHistory *helpHistory;
NSString *helpHTMLTemplate;
@@ -134,7 +134,8 @@
NSString *fieldIDQueryString;
- unsigned int numberOfQueries;
+ NSUInteger numberOfQueries;
+ NSUInteger queryTextViewStartPosition;
}
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index b1e49f68..108d360e 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -72,6 +72,9 @@
tableReloadAfterEditing = NO;
+ // Remember query start position for error highlighting
+ queryTextViewStartPosition = 0;
+
[self performQueries:queries withCallback:@selector(runAllQueriesCallback)];
}
@@ -112,13 +115,19 @@
}
queries = [NSArray arrayWithObject:query];
+ // Remember query start position for error highlighting
+ queryTextViewStartPosition = currentQueryRange.location;
+
// Otherwise, run the selected text.
} else {
queryParser = [[SPSQLParser alloc] initWithString:[[textView string] substringWithRange:selectedRange]];
queries = [queryParser splitSqlStringByCharacter:';'];
[queryParser release];
+
+ // Remember query start position for error highlighting
+ queryTextViewStartPosition = selectedRange.location;
}
-
+
// Invoke textStorageDidProcessEditing: for syntax highlighting and auto-uppercase
// and preserve the selection
[textView setSelectedRange:NSMakeRange(selectedRange.location, 0)];
@@ -591,11 +600,12 @@
if(errorLineNumberRange.length) // if a line number was found
{
// Get the line number
- unsigned int errorAtLine = [[errors substringWithRange:errorLineNumberRange] intValue];
- [textView selectLineNumber:errorAtLine ignoreLeadingNewLines:YES];
+ NSUInteger errorAtLine = [[errors substringWithRange:errorLineNumberRange] intValue];
+ NSUInteger lineOffset = [textView getLineNumberForCharacterIndex:queryTextViewStartPosition] - 1;
+ [textView selectLineNumber:errorAtLine+lineOffset ignoreLeadingNewLines:YES];
// Check for near message
- NSRange errorNearMessageRange = [errors rangeOfRegex:@" '(.*?)' " options:(RKLMultiline|RKLDotAll) inRange:NSMakeRange(0, [errors length]) capture:1 error:nil];
+ NSRange errorNearMessageRange = [errors rangeOfRegex:@" '(+*?)' " options:(RKLMultiline|RKLDotAll) inRange:NSMakeRange(0, [errors length]) capture:1 error:nil];
if(errorNearMessageRange.length) // if a "near message" was found
{
// Build the range to search for nearMessage (beginning from queryStartPosition to try to avoid mismatching)