aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-02-01 09:09:29 +0000
committerBibiko <bibiko@eva.mpg.de>2010-02-01 09:09:29 +0000
commitace1750e49cc8846b57f542dabc207c4579283f5 (patch)
tree543aaf1f3192d97b51a586a8fe4cdbf6cc3dc299 /Source
parent7bd741964d607063ca070d1ebde210c37fee56a0 (diff)
downloadsequelpro-ace1750e49cc8846b57f542dabc207c4579283f5.tar.gz
sequelpro-ace1750e49cc8846b57f542dabc207c4579283f5.tar.bz2
sequelpro-ace1750e49cc8846b57f542dabc207c4579283f5.zip
• improved text macro snippet logic
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.m36
1 files changed, 19 insertions, 17 deletions
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 53f8b79f..98bcebcd 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -1204,7 +1204,8 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
[self endSnippetSession];
return NO;
}
-
+
+ [[self textStorage] ensureAttributesAreFixedInRange:[self selectedRange]];
NSInteger caretPos = [self selectedRange].location;
NSInteger i, j;
NSInteger foundSnippetIndices[20]; // array to hold nested snippets
@@ -1254,8 +1255,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
currentSnippetIndex = index;
isCaretInsideASnippet = YES;
}
- // if that fails start to finish the snippet session
- if(!isCaretInsideASnippet) snippetControlCounter = -1;
}
return isCaretInsideASnippet;
@@ -2925,20 +2924,25 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// Highlight snippets coming from the Query Favorite text macro
if(snippetControlCounter > -1) {
- for(NSUInteger i=0; i<snippetControlMax; i++) {
- if(snippetControlArray[i][0] > -1) {
- // choose the colors for the snippet parts
- if(i == currentSnippetIndex) {
- [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.4] setFill];
- [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.8] setStroke];
- } else {
- [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.2] setFill];
- [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.5] setStroke];
+ // Is the caret still inside a snippet
+ if([self checkForCaretInsideSnippet]) {
+ for(NSUInteger i=0; i<snippetControlMax; i++) {
+ if(snippetControlArray[i][0] > -1) {
+ // choose the colors for the snippet parts
+ if(i == currentSnippetIndex) {
+ [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.4] setFill];
+ [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.8] setStroke];
+ } else {
+ [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.2] setFill];
+ [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.5] setStroke];
+ }
+ NSBezierPath *snippetPath = [self roundedBezierPathAroundRange: NSMakeRange(snippetControlArray[i][0],snippetControlArray[i][1]) ];
+ [snippetPath fill];
+ [snippetPath stroke];
}
- NSBezierPath *snippetPath = [self roundedBezierPathAroundRange: NSMakeRange(snippetControlArray[i][0],snippetControlArray[i][1]) ];
- [snippetPath fill];
- [snippetPath stroke];
}
+ } else {
+ [self endSnippetSession];
}
}
@@ -3156,7 +3160,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
// Re-calculate snippet ranges if snippet session is active
if(snippetControlCounter > -1 && !snippetWasJustInserted) {
- if([self checkForCaretInsideSnippet]) {
// Remove any fully nested snippets relative to the current snippet which was edited
NSInteger currentSnippetLocation = snippetControlArray[currentSnippetIndex][0];
NSInteger currentSnippetMaxRange = snippetControlArray[currentSnippetIndex][0] + snippetControlArray[currentSnippetIndex][1];
@@ -3195,7 +3198,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
}
}
- }
}
[self doSyntaxHighlighting];