From 6c6ba400ffb1809d77cacdf01bf30ecc208dd9cb Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Thu, 30 Aug 2012 18:49:37 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"Don=E2=80=99t=20refresh=20gutter=20fr?= =?UTF-8?q?om=20OakTextView"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turns out this is required in the situation where the document occupy less space than the visible document rect. In this case, inserting new lines will not resize the text view, since it has been artificially enlarged to fit the visible document rect, therefore the gutter view will not update properly when inserting new lines. I think there is a better solution than have the text view refresh the gutter, reverting is just meant as a quick fix. This reverts commit 4e2ae3c50879b44568b4d7a6371ae604290856e0. --- Frameworks/OakTextView/src/OakTextView.mm | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Frameworks/OakTextView/src/OakTextView.mm b/Frameworks/OakTextView/src/OakTextView.mm index cde5767c..ab1b5c32 100644 --- a/Frameworks/OakTextView/src/OakTextView.mm +++ b/Frameworks/OakTextView/src/OakTextView.mm @@ -127,6 +127,18 @@ struct refresh_helper_t } } + static NSView* find_gutter_view (NSView* view) + { + for(NSView* candidate in [view subviews]) + { + if([candidate isKindOfClass:NSClassFromString(@"GutterView")]) + return candidate; + else if(NSView* res = find_gutter_view(candidate)) + return res; + } + return nil; + } + ~refresh_helper_t () { if(--_self.refreshNestCount == 0) @@ -156,8 +168,18 @@ struct refresh_helper_t if(!NSEqualSizes([_self frame].size, newSize)) [_self setFrameSize:newSize]; + NSView* gutterView = find_gutter_view([[_self enclosingScrollView] superview]); iterate(rect, damagedRects) + { [_self setNeedsDisplayInRect:*rect]; + if(gutterView) + { + NSRect r = *rect; + r.origin.x = 0; + r.size.width = NSWidth([gutterView frame]); + [gutterView setNeedsDisplayInRect:r]; + } + } if(_revision != _document->buffer().revision() || _selection != _editor->ranges()) {