aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CustomQuery.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-10-24 21:36:51 +0000
committerBibiko <bibiko@eva.mpg.de>2009-10-24 21:36:51 +0000
commite7b2c58d61b3a815de977d0266749197b03b330c (patch)
treecc57c6145b7db90f223e83e668d260e8269a7179 /Source/CustomQuery.m
parenta5177fe6ec1107f97c326982a77100324532ccc0 (diff)
downloadsequelpro-e7b2c58d61b3a815de977d0266749197b03b330c.tar.gz
sequelpro-e7b2c58d61b3a815de977d0266749197b03b330c.tar.bz2
sequelpro-e7b2c58d61b3a815de977d0266749197b03b330c.zip
• improved error highlighting
- remember the start position of query/queries and calculate an offset for error highlighting (this fixes issue 442 mostly) - avoid highlighting of empty "near messages"
Diffstat (limited to 'Source/CustomQuery.m')
-rw-r--r--Source/CustomQuery.m18
1 files changed, 14 insertions, 4 deletions
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)