@@ -113,7 +113,6 @@ - (instancetype)initWithEditor:(IDESourceCodeEditor *)editor
113113 self.editor = editor;
114114
115115 self.editorTextView = editor.textView ;
116- [self .editorTextView.foldingManager setDelegate: self ];
117116
118117 [self setWantsLayer: YES ];
119118 [self setAutoresizingMask: NSViewMinXMargin | NSViewMinYMargin | NSViewWidthSizable | NSViewHeightSizable];
@@ -132,7 +131,15 @@ - (instancetype)initWithEditor:(IDESourceCodeEditor *)editor
132131 [self addSubview: self .scrollView];
133132
134133 self.textView = [[DVTSourceTextView alloc ] init ];
135- [self .textView setTextStorage: self .editorTextView.textStorage];
134+
135+ // The editor's layout manager needs to be the last one, otherwise live issues don't work
136+ NSTextStorage *storage = self.editorTextView .textStorage ;
137+ [storage removeLayoutManager: self .editorTextView.layoutManager];
138+ [storage addLayoutManager: self .textView.layoutManager];
139+ [storage addLayoutManager: self .editorTextView.layoutManager];
140+
141+ [self .editorTextView.foldingManager setDelegate: self ];
142+
136143 [self .textView setEditable: NO ];
137144 [self .textView setSelectable: NO ];
138145
@@ -336,7 +343,8 @@ - (void)foldingManager:(DVTFoldingManager *)foldingManager didFoldRange:(NSRange
336343
337344 [self .textView.foldingManager foldRange: range];
338345
339- [self invalidateLayoutForVisibleMinimapRange ];
346+ [self .textView.layoutManager ensureLayoutForTextContainer: self .textView.textContainer];
347+ [self updateOffset ];
340348}
341349
342350- (void )foldingManager : (DVTFoldingManager *)foldingManager didUnfoldRange : (NSRange )range
@@ -345,7 +353,8 @@ - (void)foldingManager:(DVTFoldingManager *)foldingManager didUnfoldRange:(NSRan
345353
346354 [self .textView.foldingManager unfoldRange: range];
347355
348- [self invalidateLayoutForVisibleMinimapRange ];
356+ [self .textView.layoutManager ensureLayoutForTextContainer: self .textView.textContainer];
357+ [self updateOffset ];
349358}
350359
351360#pragma mark - DBGBreakpointAnnotationProviderDelegate
@@ -576,10 +585,4 @@ - (void)invalidateDisplayForVisibleRange
576585 [self .editorTextView.layoutManager invalidateDisplayForCharacterRange: visibleEditorRange];
577586}
578587
579- - (void )invalidateLayoutForVisibleMinimapRange
580- {
581- NSRange visibleMinimapRange = [self .textView visibleCharacterRange ];
582- [self .textView.layoutManager invalidateLayoutForCharacterRange: visibleMinimapRange actualCharacterRange: nil ];
583- }
584-
585588@end
0 commit comments