aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPTextView.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2011-01-24 14:10:47 +0000
committerBibiko <bibiko@eva.mpg.de>2011-01-24 14:10:47 +0000
commit46a03988501d393085ea01956460e24f63fb257c (patch)
treece789528ec0c9af4604dfc5e737be607f259ab09 /Source/SPTextView.m
parentf1b7ccbcdd139a040adb8caae3366f998b2df75a (diff)
downloadsequelpro-46a03988501d393085ea01956460e24f63fb257c.tar.gz
sequelpro-46a03988501d393085ea01956460e24f63fb257c.tar.bz2
sequelpro-46a03988501d393085ea01956460e24f63fb257c.zip
• some minor code cleaning and improvements
Diffstat (limited to 'Source/SPTextView.m')
-rw-r--r--Source/SPTextView.m54
1 files changed, 35 insertions, 19 deletions
diff --git a/Source/SPTextView.m b/Source/SPTextView.m
index 734949f1..82bfdedf 100644
--- a/Source/SPTextView.m
+++ b/Source/SPTextView.m
@@ -2341,7 +2341,14 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
- (void)moveWordRight:(id)sender
{
[super moveWordRight:sender];
- while([self selectedRange].location < [[[self textStorage] string] length] && [[[self textStorage] string] characterAtIndex:[self selectedRange].location] == '.')
+ NSCharacterSet *whiteSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
+ while([self selectedRange].location < [[[self textStorage] string] length]
+ && ([[[self textStorage] string] characterAtIndex:[self selectedRange].location] == '.'
+ || (
+ [[[self textStorage] string] characterAtIndex:[self selectedRange].location-1] == '.'
+ && ![whiteSet characterIsMember:[[[self textStorage] string] characterAtIndex:[self selectedRange].location]]
+ )
+ ))
[super moveWordRight:sender];
}
@@ -2362,22 +2369,41 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
- (void)moveWordRightAndModifySelection:(id)sender
{
[super moveWordRightAndModifySelection:sender];
- while(NSMaxRange([self selectedRange]) < [[[self textStorage] string] length] && [[[self textStorage] string] characterAtIndex:NSMaxRange([self selectedRange])] == '.')
+ NSCharacterSet *whiteSet = [NSCharacterSet whitespaceAndNewlineCharacterSet];
+ while(NSMaxRange([self selectedRange]) < [[[self textStorage] string] length]
+ && ([[[self textStorage] string] characterAtIndex:NSMaxRange([self selectedRange])] == '.'
+ || (
+ [[[self textStorage] string] characterAtIndex:NSMaxRange([self selectedRange])-1] == '.'
+ && ![whiteSet characterIsMember:[[[self textStorage] string] characterAtIndex:NSMaxRange([self selectedRange])]]
+ )
+ ))
[super moveWordRightAndModifySelection:sender];
}
- (void) deleteBackward:(id)sender
{
- // If the caret is currently inside a marked auto-pair, delete the characters on both sides
- // of the caret.
NSRange currentRange = [self selectedRange];
- if (currentRange.length == 0 && currentRange.location > 0 && [self areAdjacentCharsLinked])
- [self setSelectedRange:NSMakeRange(currentRange.location - 1,2)];
- // Avoid auto-uppercasing if resulting word would be a SQL keyword;
- // e.g. type inta| and deleteBackward:
- delBackwardsWasPressed = YES;
+ if (currentRange.length == 0) {
+
+ // If the caret is currently inside a marked auto-pair, delete the characters on both sides
+ // of the caret.
+ if (currentRange.location > 0 && [self areAdjacentCharsLinked]) {
+ [self setSelectedRange:NSMakeRange(currentRange.location - 1,2)];
+ // Avoid auto-uppercasing if resulting word would be a SQL keyword;
+ // e.g. type inta| and deleteBackward:
+ delBackwardsWasPressed = YES;
+ }
+
+ // Remove soft indent if active and left from caret are only white spaces
+ else if ([prefs boolForKey:SPCustomQuerySoftIndent] && [self isCaretAtIndentPositionIgnoreLineStart:NO])
+ {
+ [self shiftSelectionLeft];
+ return;
+ }
+
+ }
[super deleteBackward:sender];
@@ -2431,16 +2457,6 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse)
}
// Remove soft indent if active and left from caret are only white spaces
- if (aSelector == @selector(deleteBackward:)
- && ![self selectedRange].length
- && [prefs boolForKey:SPCustomQuerySoftIndent]
- && [self isCaretAtIndentPositionIgnoreLineStart:NO])
- {
- [self shiftSelectionLeft];
- return;
- }
-
- // Remove soft indent if active and left from caret are only white spaces
if (aSelector == @selector(deleteForward:)
&& ![self selectedRange].length
&& [prefs boolForKey:SPCustomQuerySoftIndent]