From d631fe00017b5ee9bd3c8350c074f9e7567fbaca Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Wed, 17 Aug 2011 10:44:50 +0000 Subject: [PATCH] Fix bug #7662: Incorrect scrolling for rows with larger ascent. - After introducing the displayed vertical alignment for tables, we met for the first time situations in which row.ascent is very large. To make sure the scrolling still works, we have to do the same as we did for rows with a large descent. - change row.ascent into defaultRowHeight. Before the above mentioned change, row.ascent usually was approximately the same as defaultRowHeight (by chance). However, it is now clear we don't really want row.ascent here. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39486 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 7076cc8989..8fa8a036bc 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -888,16 +888,25 @@ bool BufferView::scrollToCursor(DocIterator const & dit, bool recenter) // If the top part of the row falls of the screen, we scroll // up to align the top of the row with the top of the screen. - else if (ypos - row_dim.ascent() < 0) - scrolled = scrollUp(-ypos + row_dim.ascent()); + else if (ypos - row_dim.ascent() < 0 && ypos < height_) { + int ynew = row_dim.ascent(); + if (ynew > height_ - row_dim.descent()) + // FIXME: Recursively find the rowheight of the row in the inset + // until we find a row which can be visualized completely. + ynew = height_ - defaultRowHeight(); + int const scroll = ynew - ypos; + scrolled = scrollUp(scroll); + } // If the bottom of the row falls of the screen, we scroll down. // However, we have to be careful not to scroll that much that // the top falls of the screen. - else if (ypos + row_dim.descent() > height_) { + else if (ypos + row_dim.descent() > height_ && ypos > 0) { int ynew = height_ - row_dim.descent(); if (ynew < row_dim.ascent()) - ynew = row_dim.ascent(); + // FIXME: Recursively find the rowheight of the row in the inset + // until we find a row which can be visualized completely. + ynew = defaultRowHeight(); int const scroll = ypos - ynew; scrolled = scrollDown(scroll); } -- 2.39.2