@@ -198,9 +198,12 @@ - (void)drawRect:(NSRect)rect
198198 // looking tabs. However, the textured window background looks really
199199 // weird behind the window resize throbber, so emulate the look of an
200200 // NSScrollView in the bottom right corner.
201- if (![[self window ] showsResizeIndicator ] // XXX: make this a flag
201+ if (![[self window ] showsResizeIndicator ]
202202 || !([[self window ] styleMask ] & NSWindowStyleMaskTexturedBackground ))
203203 return ;
204+
205+ // This should not be reachable in 10.7 or above and is deprecated code.
206+ // See documentation for showsResizeIndicator and placeScrollbars: comments.
204207
205208#if (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)
206209 int sw = [NSScroller scrollerWidthForControlSize: NSControlSizeRegular scrollerStyle: NSScrollerStyleLegacy];
@@ -389,7 +392,7 @@ - (void)selectTabWithIndex:(int)idx
389392 vimTaskSelectedTab = NO ;
390393
391394 // We might need to change the scrollbars that are visible.
392- [ self placeScrollbars ] ;
395+ self. pendingPlaceScrollbars = YES ;
393396 }
394397}
395398
@@ -424,6 +427,8 @@ - (void)createScrollbarWithIdentifier:(int32_t)ident type:(int)type
424427 [self addSubview: scroller];
425428 [scrollbars addObject: scroller];
426429 [scroller release ];
430+
431+ self.pendingPlaceScrollbars = YES ;
427432}
428433
429434- (BOOL )destroyScrollbarWithIdentifier : (int32_t )ident
@@ -434,6 +439,8 @@ - (BOOL)destroyScrollbarWithIdentifier:(int32_t)ident
434439
435440 [scroller removeFromSuperview ];
436441 [scrollbars removeObjectAtIndex: idx];
442+
443+ self.pendingPlaceScrollbars = YES ;
437444
438445 // If a visible scroller was removed then the vim view must resize. This
439446 // is handled by the window controller (the vim view never resizes itself).
@@ -447,6 +454,8 @@ - (BOOL)showScrollbarWithIdentifier:(int32_t)ident state:(BOOL)visible
447454
448455 BOOL wasVisible = ![scroller isHidden ];
449456 [scroller setHidden: !visible];
457+
458+ self.pendingPlaceScrollbars = YES ;
450459
451460 // If a scroller was hidden or shown then the vim view must resize. This
452461 // is handled by the window controller (the vim view never resizes itself).
@@ -483,10 +492,16 @@ - (void)setScrollbarPosition:(int)pos length:(int)len identifier:(int32_t)ident
483492 NSRange range = NSMakeRange (pos, len);
484493 if (!NSEqualRanges (range, [scroller range ])) {
485494 [scroller setRange: range];
486- // TODO! Should only do this once per update.
487-
488495 // This could be sent because a text window was created or closed, so
489496 // we might need to update which scrollbars are visible.
497+ }
498+ self.pendingPlaceScrollbars = YES ;
499+ }
500+
501+ - (void )finishPlaceScrollbars
502+ {
503+ if (self.pendingPlaceScrollbars ) {
504+ self.pendingPlaceScrollbars = NO ;
490505 [self placeScrollbars ];
491506 }
492507}
@@ -789,7 +804,7 @@ - (void)placeScrollbars
789804
790805 // Vertical scrollers must not cover the resize box in the
791806 // bottom-right corner of the window.
792- if ([[self window ] showsResizeIndicator ] // XXX: make this a flag
807+ if ([[self window ] showsResizeIndicator ] // Note: This is deprecated as of 10.7, see below comment.
793808 && rect.origin .y < scrollerWidth) {
794809 rect.size .height -= scrollerWidth - rect.origin .y ;
795810 rect.origin .y = scrollerWidth;
@@ -914,7 +929,7 @@ - (void)frameSizeMayHaveChanged:(BOOL)keepGUISize
914929 NSRect textViewRect = [self textViewRectForVimViewSize: [self frame ].size];
915930 [textView setFrame: textViewRect];
916931
917- [ self placeScrollbars ] ;
932+ self. pendingPlaceScrollbars = YES ;
918933
919934 // It is possible that the current number of (rows,columns) is too big or
920935 // too small to fit the new frame. If so, notify Vim that the text
0 commit comments