Apply indent conversion to whole document if no text selected (#533)

This commit is contained in:
1024jp 2016-03-28 01:40:48 +09:00
parent daa56552dc
commit 2444ae121c
2 changed files with 21 additions and 5 deletions

View File

@ -23,7 +23,11 @@ develop
- Fix an issue where font-size changing could remove hanging indent.
- Fix an issue where layout of split editors will be broken if the font of one of the other split editors is changed.
- Add “Copy as Rich Text” action to the contextual menu.
- Apply “Sort”, “Reverse” or “Delete Duplicates” actions for text lines to whole document if no text is selected.
- Apply the following text actions to whole document if no text is selected:
- Indentation > Convert Indentation to Tab / Spaces
- Lines > Sort
- Lines > Reverse
- Lines > Delete Duplicates
- Improve recovering status of unsaved documents on window resume.
- Improve line number view drawing with selection on vertical text mode.
- Improve invisibles drawing:

View File

@ -165,9 +165,14 @@
- (IBAction)convertIndentationToSpaces:(nullable id)sender
// ------------------------------------------------------
{
if ([self selectedRange].length == 0) { return; }
NSArray<NSValue *> *ranges;
if ([self selectedRange].length == 0) {
ranges = @[[NSValue valueWithRange:NSMakeRange(0, [[self string] length])]];
} else {
ranges = [self selectedRanges];
}
[self convertIndentation:CEIndentStyleSpace inRanges:[self selectedRanges]];
[self convertIndentation:CEIndentStyleSpace inRanges:ranges];
}
@ -176,9 +181,14 @@
- (IBAction)convertIndentationToTabs:(nullable id)sender
// ------------------------------------------------------
{
if ([self selectedRange].length == 0) { return; }
NSArray<NSValue *> *ranges;
if ([self selectedRange].length == 0) {
ranges = @[[NSValue valueWithRange:NSMakeRange(0, [[self string] length])]];
} else {
ranges = [self selectedRanges];
}
[self convertIndentation:CEIndentStyleTab inRanges:[self selectedRanges]];
[self convertIndentation:CEIndentStyleTab inRanges:ranges];
}
@ -190,6 +200,8 @@
- (void)convertIndentation:(CEIndentStyle)indentStyle inRanges:(nonnull NSArray<NSValue *> *)ranges
// ------------------------------------------------------
{
if ([[self string] length] == 0) { return; }
NSMutableArray<NSValue *> *replacementRanges = [NSMutableArray arrayWithCapacity:[ranges count]];
NSMutableArray<NSString *> *replacementStrings = [NSMutableArray arrayWithCapacity:[ranges count]];