Jürgen Spitzmüller schreef:
Vincent van Ravesteijn wrote:
- we can disable the assertion for PgUp/PgDwn, because it doesn't work
anyway (there is another bug that the cursor is not placed inside insets),

Probably a good idea, since assertions seem to be persistent on Windows.

Jürgen
This fixes it (I hope),

Vincent
Index: src/TextMetrics.cpp
===================================================================
--- src/TextMetrics.cpp (revision 30901)
+++ src/TextMetrics.cpp (working copy)
@@ -1370,7 +1370,7 @@
 }
 
 
-Row const & TextMetrics::getPitAndRowNearY(int y, pit_type & pit,
+Row const & TextMetrics::getPitAndRowNearY(int & y, pit_type & pit,
        bool assert_in_view, bool up)
 {
        ParagraphMetrics const & pm = par_metrics_[pit];
@@ -1386,23 +1386,27 @@
 
        if (assert_in_view && yy + rit->height() != y) {
                if (!up) {
-                       if (rit != pm.rows().begin())
+                       if (rit != pm.rows().begin()) {
+                               y = yy;
                                --rit;
-                       else if (pit != 0) {
+                       } else if (pit != 0) {
                                --pit;
                                newParMetricsUp();
                                ParagraphMetrics const & pm2 = 
par_metrics_[pit];
                                rit = pm2.rows().end();
                                --rit;
+                               y = yy;
                        }
                } else  {
-                       if (rit != rlast)
+                       if (rit != rlast) {
+                               y = yy + rit->height();
                                ++rit;
-                       else if (pit != int(par_metrics_.size())) {
+                       } else if (pit != int(par_metrics_.size())) {
                                ++pit;
                                newParMetricsDown();
                                ParagraphMetrics const & pm2 = 
par_metrics_[pit];
                                rit = pm2.rows().begin();
+                               y = pm2.position();
                        }
                }
        }
@@ -1421,8 +1425,8 @@
        }
        pit_type pit = getPitNearY(y);
        LASSERT(pit != -1, return 0);
-
-       Row const & row = getPitAndRowNearY(y, pit, assert_in_view, up);
+       int yy = y; // is modified by getPitAndRowNearY
+       Row const & row = getPitAndRowNearY(yy, pit, assert_in_view, up);
        bool bound = false;
 
        int xx = x; // is modified by getColumnNearX
@@ -1434,8 +1438,8 @@
        cur.setTargetX(x);
 
        // try to descend into nested insets
-       Inset * inset = checkInsetHit(x, y);
-       //lyxerr << "inset " << inset << " hit at x: " << x << " y: " << y << 
endl;
+       Inset * inset = checkInsetHit(x, yy);
+       //lyxerr << "inset " << inset << " hit at x: " << x << " y: " << yy << 
endl;
        if (!inset) {
                // Either we deconst editXY or better we move current_font
                // and real_current_font to Cursor
@@ -1446,7 +1450,7 @@
        }
 
        ParagraphList const & pars = text_->paragraphs();
-       Inset const * insetBefore = pos? pars[pit].getInset(pos - 1): 0;
+       Inset const * insetBefore = pos ? pars[pit].getInset(pos - 1): 0;
        //Inset * insetBehind = pars[pit].getInset(pos);
 
        // This should be just before or just behind the
@@ -1462,7 +1466,7 @@
        }
 
        // Try to descend recursively inside the inset.
-       inset = inset->editXY(cur, x, y);
+       inset = inset->editXY(cur, x, yy);
 
        if (cur.top().text() == text_)
                cur.setCurrentFont();
Index: src/TextMetrics.h
===================================================================
--- src/TextMetrics.h   (revision 30901)
+++ src/TextMetrics.h   (working copy)
@@ -179,7 +179,7 @@
        /// returns the row near the specified y-coordinate in a given paragraph
        /// (relative to the screen). If assert_in_view is true, it is made sure
        /// that the row is on screen completely; this might change the given 
pit.
-       Row const & getPitAndRowNearY(int y, pit_type & pit,
+       Row const & getPitAndRowNearY(int & y, pit_type & pit,
                bool assert_in_view, bool up);
 
        /// returns the paragraph number closest to screen y-coordinate.

Reply via email to