aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-07-16 17:21:43 +0000
committerBibiko <bibiko@eva.mpg.de>2009-07-16 17:21:43 +0000
commit3d94ef3ed65c30139ded428b477fac673a29c1ee (patch)
tree52af215a64ffddcf3633d66e06703ec546c33a1c /Source
parente21905eda02d5fffebf9cfb5ac7fa825e30860d7 (diff)
downloadsequelpro-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')
-rw-r--r--Source/CustomQuery.m17
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