Fix toggling invisibiles visibility (fix #510)

This commit is contained in:
1024jp 2016-02-25 02:08:19 +09:00
parent a2432dcc92
commit d96ade606d
4 changed files with 23 additions and 15 deletions

View File

@ -21,6 +21,7 @@ develop
- Fix an issue where documents were marked as “Edited” just after opening file if “link URL” option is enabled.
- Fix an issue where URL link was not applied to pasted text.
- Fix an issue where find-all highlight wasn't removed if find panel is closed before closing find result view.
- Fix an issue where toggling invisible visibility didn't work correctly.

View File

@ -192,17 +192,6 @@
// ------------------------------------------------------
{
[(CELayoutManager *)[[self textView] layoutManager] setShowsInvisibles:showsInvisibles];
//
// ... 2006-09-25
if (showsInvisibles) {
__block NSTextView *textView = [self textView];
dispatch_async(dispatch_get_main_queue(), ^{
NSRange selectedRange = [textView selectedRange];
[textView setSelectedRange:NSMakeRange(0, 0)];
[textView setSelectedRange:selectedRange];
});
}
}

View File

@ -592,11 +592,9 @@
- (IBAction)toggleInvisibleChars:(nullable id)sender
// ------------------------------------------------------
{
BOOL showsInvisibles = ![(CELayoutManager *)[[self focusedTextView] layoutManager] showsInvisibles];
BOOL showsInvisibles = ![self showsInvisibles];
[self setShowsInvisibles:showsInvisibles];
[[self splitViewController] enumerateEditorViewsUsingBlock:^(CEEditorViewController * _Nonnull viewController) {
[viewController setShowsInvisibles:showsInvisibles];
}];
[[[self windowController] toolbarController] toggleItemWithTag:CEToolbarShowInvisibleCharsItemTag
setOn:showsInvisibles];
}

View File

@ -315,6 +315,26 @@ static BOOL usesTextFontForInvisibles;
}
// ------------------------------------------------------
/// update invisible characters visibility if needed
- (void)setShowsInvisibles:(BOOL)showsInvisibles
// ------------------------------------------------------
{
if (showsInvisibles == _showsInvisibles) { return; }
_showsInvisibles = showsInvisibles;
NSRange wholeRange = NSMakeRange(0, [[self textStorage] length]);
if ([self showsOtherInvisibles]) {
// -> force recaluculate layout in order to make spaces for control characters drawing
[self invalidateGlyphsForCharacterRange:wholeRange changeInLength:0 actualCharacterRange:NULL];
[self invalidateLayoutForCharacterRange:wholeRange actualCharacterRange:NULL];
} else {
[self invalidateDisplayForCharacterRange:wholeRange];
}
}
// ------------------------------------------------------
///
- (CGFloat)lineHeight