]> git.lyx.org Git - features.git/commitdiff
Fix ghost caret properpaint
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 8 Jan 2018 10:49:40 +0000 (11:49 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 15 Feb 2018 11:29:25 +0000 (12:29 +0100)
This fixes a regression in e64ea357, where a test has been (badly)
tightened to avoid that two consecutive rows may be redrawn to get rid
of caret ghosts. The test prohibited empty rows from being redrawn.

Moreover, improve the test of cursor boundary to avoid the case where
cursor position is already 0.

Fixes bug #10952.

(cherry picked from commit 66c677b9463feb0687a8228603f86eddd4e859fd)

src/BufferView.cpp

index 23d0055221e6aa30334c687c04cddc9a92b35f94..36ac46cddea813e17fd7b643573699edbfa98fb0 100644 (file)
@@ -2978,8 +2978,14 @@ namespace {
 
 bool sliceInRow(CursorSlice const & cs, Text const * text, Row const & row)
 {
+       /* The normal case is the last line. The previous line takes care
+        * of empty rows (e.g. empty paragraphs). Cursor boundary issues
+        * are taken care of when setting caret_slice_ in
+        * BufferView::draw.
+        */
        return !cs.empty() && cs.text() == text && cs.pit() == row.pit()
-               && row.pos() <= cs.pos() && cs.pos() < row.endpos();
+              && ((row.pos() == row.endpos() && row.pos() == cs.pos())
+                 || (row.pos() <= cs.pos() && cs.pos() < row.endpos()));
 }
 
 }
@@ -3164,8 +3170,9 @@ void BufferView::draw(frontend::Painter & pain, bool paint_caret)
        // Remember what has just been done for the next draw() step
        if (paint_caret) {
                d->caret_slice_ = d->cursor_.top();
-               if (d->cursor_.boundary()
-                   || d->cursor_.top().pos() == d->cursor_.top().lastpos())
+               if (d->caret_slice_.pos() > 0
+                   && (d->cursor_.boundary()
+                       || d->caret_slice_.pos() == d->caret_slice_.lastpos()))
                        --d->caret_slice_.pos();
        } else
                d->caret_slice_ = CursorSlice();