2727
2828#import " DVTAnnotationManager.h"
2929#import " DBGBreakpointAnnotationProvider+SCXcodeMinimap.h"
30+ #import " DBGBreakpointAnnotation+SCXcodeMinimap.h"
3031#import " DBGBreakpointAnnotation.h"
3132
3233const CGFloat kBackgroundColorShadowLevel = 0 .1f ;
@@ -80,6 +81,8 @@ @interface SCXcodeMinimapView () <NSLayoutManagerDelegate, DVTFoldingManagerDele
8081@property (nonatomic , strong ) SCXcodeMinimapTheme *editorTheme;
8182
8283@property (nonatomic , assign ) BOOL shouldAllowFullSyntaxHighlight;
84+
85+ @property (nonatomic , assign ) BOOL shouldUpdateBreakpoints;
8386@property (nonatomic , strong ) NSMutableArray *breakpointDictionaries;
8487
8588@property (nonatomic , weak ) DBGBreakpointAnnotationProvider *breakpointAnnotationProvider;
@@ -92,6 +95,7 @@ - (void)dealloc
9295{
9396 [[NSNotificationCenter defaultCenter ] removeObserver: self ];
9497 [self .textView.textStorage removeLayoutManager: self .textView.layoutManager];
98+ [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector (invalidateDisplayForVisibleRange ) object: nil ];
9599}
96100
97101- (instancetype )initWithEditor : (IDESourceCodeEditor *)editor
@@ -135,11 +139,12 @@ - (instancetype)initWithEditor:(IDESourceCodeEditor *)editor
135139 for (NSDictionary *providerDictionary in self.editorTextView .annotationManager .annotationProviders ) {
136140 if ([providerDictionary[@" annotationProviderObject" ] isKindOfClass: [DBGBreakpointAnnotationProvider class ]]) {
137141 self.breakpointAnnotationProvider = providerDictionary[@" annotationProviderObject" ];
138- [self .breakpointAnnotationProvider setDelegate :self ];
142+ [self .breakpointAnnotationProvider setMinimapDelegate :self ];
139143 break ;
140144 }
141145 }
142146
147+ self.shouldUpdateBreakpoints = YES ;
143148 [self invalidateDisplayForVisibleRange ];
144149 }
145150
@@ -258,11 +263,12 @@ - (NSDictionary *)layoutManager:(NSLayoutManager *)layoutManager
258263 if (self.breakpointDictionaries .count ) {
259264 for (NSDictionary *breakpointDictionary in self.breakpointDictionaries ) {
260265 NSRange range = [breakpointDictionary[kBreakpointRangeKey ] rangeValue ];
266+ BOOL enabled = [breakpointDictionary[kBreakpointEnabledKey ] boolValue ];
261267
262268 if (NSIntersectionRange (range, NSMakeRange (charIndex, 1 )).length ) {
263269 *effectiveCharRange = range;
264270 return @{NSForegroundColorAttributeName : theme.sourceTextBackgroundColor ,
265- NSBackgroundColorAttributeName : theme.enabledBreakpointColor };
271+ NSBackgroundColorAttributeName : (enabled ? theme.enabledBreakpointColor : theme. disabledBreakpointColor ) };
266272 }
267273 }
268274 }
@@ -327,7 +333,10 @@ - (void)foldingManager:(DVTFoldingManager *)foldingManager didUnfoldRange:(NSRan
327333
328334- (void )breakpointAnnotationProviderDidChangeBreakpoints : (DBGBreakpointAnnotationProvider *)annotationProvider
329335{
330- [self invalidateDisplayForVisibleRange ];
336+ self.shouldUpdateBreakpoints = YES ;
337+
338+ [NSObject cancelPreviousPerformRequestsWithTarget: self selector: @selector (invalidateDisplayForVisibleRange ) object: nil ];
339+ [self performSelector: @selector (invalidateDisplayForVisibleRange ) withObject: nil afterDelay: kDurationBetweenInvalidations ];
331340}
332341
333342- (void )updateBreakpoints
@@ -346,12 +355,14 @@ - (void)updateBreakpoints
346355
347356 for (DBGBreakpointAnnotation *breakpointAnnotation in self.breakpointAnnotationProvider .annotations ) {
348357 if (breakpointAnnotation.paragraphRange .location == lineNumber) {
349- [self .breakpointDictionaries addObject: @{kBreakpointRangeKey : [NSValue valueWithRange: lineRange]}];
358+ [self .breakpointDictionaries addObject: @{kBreakpointRangeKey : [NSValue valueWithRange: lineRange], kBreakpointEnabledKey : @(breakpointAnnotation. enabled ) }];
350359 }
351360 }
352361
353362 index = NSMaxRange (lineRange);
354363 }
364+
365+ self.shouldUpdateBreakpoints = NO ;
355366}
356367
357368#pragma mark - Navigation
@@ -511,9 +522,11 @@ - (void)resizeWithOldSuperviewSize:(NSSize)oldSize
511522
512523- (void )invalidateDisplayForVisibleRange
513524{
514- self.shouldAllowFullSyntaxHighlight = YES ;
525+ if (self.shouldUpdateBreakpoints ) {
526+ [self updateBreakpoints ];
527+ }
515528
516- [ self updateBreakpoints ] ;
529+ self. shouldAllowFullSyntaxHighlight = YES ;
517530
518531 NSRange visibleMinimapRange = [self .textView visibleCharacterRange ];
519532 [self .textView.layoutManager invalidateDisplayForCharacterRange: visibleMinimapRange];
0 commit comments