From f38483d441f465443253cd4ea51d35208e676b09 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Fri, 6 Nov 2009 18:08:06 +0000 Subject: [PATCH] branch: Fix bug #6237: The boundary has to be set correctly when moving up with a selection. If not, the cursor will remain on the same row when there are two e.g. displayed equations after each other. This will cause an infinite loop when SCREEN_UP is executed. (I added a small extra safety measure to not change the logic resulting from r31864. I'm not sure it can harm.) see r31863, r31864. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@31880 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Cursor.cpp | 22 +++++++++++++++++----- status.16x | 3 +++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 0af4dde3c7..d68fef41d8 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -1859,31 +1859,43 @@ bool Cursor::upDownInText(bool up, bool & updateNeeded) operator=(dummy); } } else { - // if there is a selection, we stay out of any inset, and just jump to the right position: + // if there is a selection, we stay out of any inset, + // and just jump to the right position: Cursor old = *this; + int next_row = row; + bool update = false; if (up) { if (row > 0) { - top().pos() = min(tm.x2pos(pit(), row - 1, xo), top().lastpos()); + --next_row; + update = true; } else if (pit() > 0) { --pit(); TextMetrics & tm = bv_->textMetrics(text()); if (!tm.contains(pit())) tm.newParMetricsUp(); ParagraphMetrics const & pmcur = tm.parMetrics(pit()); - top().pos() = min(tm.x2pos(pit(), pmcur.rows().size() - 1, xo), top().lastpos()); + next_row = pmcur.rows().size() - 1; + update = true; } } else { if (row + 1 < int(pm.rows().size())) { - top().pos() = min(tm.x2pos(pit(), row + 1, xo), top().lastpos()); + ++next_row; + update = true; } else if (pit() + 1 < int(text()->paragraphs().size())) { ++pit(); TextMetrics & tm = bv_->textMetrics(text()); if (!tm.contains(pit())) tm.newParMetricsDown(); - top().pos() = min(tm.x2pos(pit(), 0, xo), top().lastpos()); + next_row = 0; + update = true; } } + if (update) { + top().pos() = min(tm.x2pos(pit(), next_row, xo), top().lastpos()); + boundary(tm.x2pos(pit(), next_row, xo) + == tm.x2pos(pit(), next_row, tm.width())); + } updateNeeded |= bv().checkDepm(*this, old); } diff --git a/status.16x b/status.16x index cf23b4f27d..a3a9cd3898 100644 --- a/status.16x +++ b/status.16x @@ -192,6 +192,9 @@ What's new - Fix a crash when leaving an empty superscript or subscript (bug 6193). +- Fix an infinite loop when selecting multiple displayed equation right + after each other with LFUN_SCREEN_UP (bug 6237). + - Fix a number of assertions when displaying error messages (bug 6205). - Fix bad allocation exception when displaying long tooltips (bug 6215).