From cda56c0dc3d5e43b68b464fa1a483d8973d2b692 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 28 Sep 2017 13:31:41 +0200 Subject: [PATCH] Avoid empty space above the top of the document If the height of the first row of the document has become smaller (for example when it contains an image which size has shrunk), that the anchor offset has to be adapted so that there is not a large blank space at the top of the document. (cherry picked from commit d6aecbda0f5929ab04805ac6e19cd48f3c4a059b) --- src/BufferView.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index d2215627cf..49be7be9e2 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -2698,10 +2698,10 @@ void BufferView::updateMetrics() // Complete buffer visible? Then it's easy. if (scrollRange == 0) d->anchor_ypos_ = anchor_pm.ascent(); - - // FIXME: Some clever handling needed to show - // the _first_ paragraph up to the top if the cursor is - // in the first line. + else { + // avoid empty space above the first row + d->anchor_ypos_ = min(d->anchor_ypos_, anchor_pm.ascent()); + } } anchor_pm.setPosition(d->anchor_ypos_); -- 2.39.5