mirror of
https://github.com/coteditor/CotEditor.git
synced 2024-09-11 11:25:57 +03:00
Fix toggling invisibiles visibility (fix #510)
This commit is contained in:
parent
a2432dcc92
commit
d96ade606d
@ -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.
|
||||
|
||||
|
||||
|
||||
|
@ -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];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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];
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user