]> git.lyx.org Git - features.git/commitdiff
Avoid empty space above the top of the document
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 28 Sep 2017 11:31:41 +0000 (13:31 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 28 Sep 2017 11:57:36 +0000 (13:57 +0200)
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

index d2215627cfbdb2ef7be4b54793ce4dc5ed78dd99..49be7be9e2ec70f517aca962d14f416f1864da02 100644 (file)
@@ -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_);