aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-01-09 22:07:25 +0100
committerMax <post@wickenrode.com>2015-01-09 22:07:25 +0100
commitdcfe99612cadd055599acd2070d4d9ac49633a95 (patch)
tree31d0beff8241fb1faed3ba9fa684df06b22326bd
parent69b519cb18762cd1b1596d50346f24e233cb8e29 (diff)
downloadsequelpro-dcfe99612cadd055599acd2070d4d9ac49633a95.tar.gz
sequelpro-dcfe99612cadd055599acd2070d4d9ac49633a95.tar.bz2
sequelpro-dcfe99612cadd055599acd2070d4d9ac49633a95.zip
Unescape escaped mirrored snippets in query fav.
fixes #2049
-rw-r--r--Source/SPTextView.m30
1 files changed, 16 insertions, 14 deletions
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index c3ebf394..f50ed939 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -1934,20 +1934,22 @@ static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NS
}
// unescape escaped snippets and re-adjust successive snippet locations : \${1:a} → ${1:a}
- NSString *ure = @"(?s)\\\\\\$\\{(1?\\d):(.{0}|.*?[^\\\\])\\}";
- while([snip isMatchedByRegex:ure]) {
- NSRange escapeRange = [snip rangeOfRegex:ure capture:0L];
- [snip replaceCharactersInRange:escapeRange withString:[snip substringWithRange:NSMakeRange(escapeRange.location+1,escapeRange.length-1)]];
- NSInteger loc = escapeRange.location + targetRange.location;
- [snip flushCachedRegexData];
- for(i=0; i<=snippetControlMax; i++)
- if(snippetControlArray[i][0] > -1 && snippetControlArray[i][0] > loc)
- snippetControlArray[i][0]--;
- // Adjust mirrored snippets
- if(mirroredCounter > -1)
- for(i=0; i<=mirroredCounter; i++)
- if(snippetMirroredControlArray[i][0] > -1 && snippetMirroredControlArray[i][1] > loc)
- snippetMirroredControlArray[i][1]--;
+ // unescape escaped mirrored snippets and re-adjust successive snippet locations : \$1 → $1
+ for (NSString *regex in @[@"(?s)\\\\\\$\\{(1?\\d):(.{0}|.*?[^\\\\])\\}",@"(?s)\\\\\\$(1?\\d)(?=\\D)"]) {
+ while([snip isMatchedByRegex:regex]) {
+ NSRange escapeRange = [snip rangeOfRegex:regex capture:0L];
+ [snip replaceCharactersInRange:escapeRange withString:[snip substringWithRange:NSMakeRange(escapeRange.location+1,escapeRange.length-1)]];
+ NSInteger loc = escapeRange.location + targetRange.location;
+ [snip flushCachedRegexData];
+ for(i=0; i<=snippetControlMax; i++)
+ if(snippetControlArray[i][0] > -1 && snippetControlArray[i][0] > loc)
+ snippetControlArray[i][0]--;
+ // Adjust mirrored snippets
+ if(mirroredCounter > -1)
+ for(i=0; i<=mirroredCounter; i++)
+ if(snippetMirroredControlArray[i][0] > -1 && snippetMirroredControlArray[i][1] > loc)
+ snippetMirroredControlArray[i][1]--;
+ }
}
// Insert favorite query by selecting the tab trigger if any