diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-10-24 21:36:51 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-10-24 21:36:51 +0000 |
commit | e7b2c58d61b3a815de977d0266749197b03b330c (patch) | |
tree | cc57c6145b7db90f223e83e668d260e8269a7179 | |
parent | a5177fe6ec1107f97c326982a77100324532ccc0 (diff) | |
download | sequelpro-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"
-rw-r--r-- | Source/CustomQuery.h | 7 | ||||
-rw-r--r-- | Source/CustomQuery.m | 18 |
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) |