diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-07-16 17:21:43 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-07-16 17:21:43 +0000 |
commit | 3d94ef3ed65c30139ded428b477fac673a29c1ee (patch) | |
tree | 52af215a64ffddcf3633d66e06703ec546c33a1c /Source/CustomQuery.m | |
parent | e21905eda02d5fffebf9cfb5ac7fa825e30860d7 (diff) | |
download | sequelpro-3d94ef3ed65c30139ded428b477fac673a29c1ee.tar.gz sequelpro-3d94ef3ed65c30139ded428b477fac673a29c1ee.tar.bz2 sequelpro-3d94ef3ed65c30139ded428b477fac673a29c1ee.zip |
• fixed minor issues for "Comment Line/Selection" in Custom Query
- esp. for (un)commenting a selection if it ends with a \n
Diffstat (limited to 'Source/CustomQuery.m')
-rw-r--r-- | Source/CustomQuery.m | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index e59f82e2..461dfba8 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -959,18 +959,23 @@ [n setString:[[textView string] substringWithRange:workingRange]]; + if([n isMatchedByRegex:@"\\n\\Z"]) { + workingRange.length--; + [n replaceOccurrencesOfRegex:@"\\n\\Z" withString:@""]; + } + // Escape given */ by *\/ [n replaceOccurrencesOfRegex:@"\\*/(?=.)" withString:@"*\\\\/"]; [n replaceOccurrencesOfRegex:@"\\*/(?=\\n)" withString:@"*\\\\/"]; // Wrap current query into /* */ [n replaceOccurrencesOfRegex:@"^" withString:@"/* "]; - [n replaceOccurrencesOfRegex:@"$" withString:@" */"]; + [n appendString:@" */"]; // Check if current query/selection is already commented out, if so uncomment it if([n isMatchedByRegex:@"^/\\* \\s*/\\*\\s*(.|\\n)*?\\s*\\*/ \\*/\\s*$"]) { [n replaceOccurrencesOfRegex:@"^/\\* \\s*/\\*\\s*" withString:@""]; - [n replaceOccurrencesOfRegex:@"\\s*\\*/ \\*/\\s*$" withString:@""]; + [n replaceOccurrencesOfRegex:@"\\s*\\*/ \\*/\\s*\\Z" withString:@""]; // unescape *\/ [n replaceOccurrencesOfRegex:@"\\*\\\\/" withString:@"*/"]; isUncomment = YES; @@ -997,7 +1002,7 @@ NSRange oldRange = [textView selectedRange]; - if(oldRange.length) { + if(oldRange.length) { // (un)comment selection [self commentOutCurrentQueryTakingSelection:YES]; } else { // single line @@ -1017,15 +1022,15 @@ inRange:NSMakeRange(0,[n length]) capture:1 error: nil]]]; - } else if ([n isMatchedByRegex:@"^-- \\s*/\\*.*?\\*/\\s*$"]) { + } else if ([n isMatchedByRegex:@"^-- \\s*/\\*.*? ?\\*/\\s*$"]) { [n replaceOccurrencesOfRegex:@"^-- \\s*/\\* ?" withString:[n substringWithRange:[n rangeOfRegex:@"^-- (\\s*)" options:RKLNoOptions inRange:NSMakeRange(0,[n length]) capture:1 error: nil]]]; - [n replaceOccurrencesOfRegex:@"\\*/\\s*$" - withString:[n substringWithRange:[n rangeOfRegex:@"\\*/(\\s*)$" + [n replaceOccurrencesOfRegex:@" ?\\*/\\s*$" + withString:[n substringWithRange:[n rangeOfRegex:@" ?\\*/(\\s*)$" options:RKLNoOptions inRange:NSMakeRange(0,[n length]) capture:1 |