mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Delete tab more naturally
This commit is contained in:
parent
6674e8540f
commit
a040ad3320
@ -26,6 +26,7 @@ develop
|
||||
- Remove “Set as Default” button in the editor opacity panel.
|
||||
- Change specification not to treat full-width spaces as indent.
|
||||
- Open sidebar inward on Yosemite.
|
||||
- Make indent deletion more naturally.
|
||||
- Remove byte count display in document inspector.
|
||||
- Display dialogs while changing file encoding as a document-modal sheet.
|
||||
- Display also an accurate file size in document inspector.
|
||||
|
@ -539,20 +539,18 @@ static NSCharacterSet *kMatchingClosingBracketsSet;
|
||||
|
||||
// delete tab
|
||||
if ((selectedRange.length == 0) && [self isAutoTabExpandEnabled]) {
|
||||
NSUInteger tabWidth = [self tabWidth];
|
||||
NSInteger column = [[self string] columnOfLocation:selectedRange.location tabWidth:tabWidth];
|
||||
NSInteger targetWidth = tabWidth - (column % tabWidth);
|
||||
NSRange indentRange = [[self string] rangeOfIndentAtIndex:selectedRange.location];
|
||||
|
||||
if (selectedRange.location >= targetWidth) {
|
||||
NSRange targetRange = NSMakeRange(selectedRange.location - targetWidth, targetWidth);
|
||||
BOOL shouldDelete = NO;
|
||||
for(NSUInteger i = targetRange.location; i < NSMaxRange(targetRange); i++ ) {
|
||||
shouldDelete = ([[self string] characterAtIndex:i] == ' ');
|
||||
|
||||
if (!shouldDelete) { break; }
|
||||
}
|
||||
if (shouldDelete) {
|
||||
[self setSelectedRange:targetRange];
|
||||
if (selectedRange.location <= NSMaxRange(indentRange)) {
|
||||
NSUInteger tabWidth = [self tabWidth];
|
||||
NSInteger column = [[self string] columnOfLocation:selectedRange.location tabWidth:tabWidth];
|
||||
NSInteger targetLength = tabWidth - (column % tabWidth);
|
||||
|
||||
if (selectedRange.location >= targetLength) {
|
||||
NSRange targetRange = NSMakeRange(selectedRange.location - targetLength, targetLength);
|
||||
if ([[[self string] substringWithRange:targetRange] isEqualToString:[NSString stringWithSpaces:targetLength]]) {
|
||||
[self setSelectedRange:targetRange];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user