Le 13/02/2025 à 23:52, Jean-Marc Lasgouttes a écrit :
commit 8cfe8d1855250086a50d874072d3629c6016f8cb
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Sat Feb 8 21:09:23 2025 +0100

     Avoid unnecessary creation of a row around caret position.
When trying to see whether the caret has affected a row, do not create
     this row (with redoParagraph) if it did not exist.

Riki,

This is candidate for branch, together with the robustification commit

commit 0fa3aba5c6ebf40738abfd3fa480c046f787766b
Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date:   Thu Jan 9 12:00:04 2025 +0100

    Check that paragraph has a position when computing cursor position


JMarc

---
  src/BufferView.cpp | 20 ++++++++++++--------
  1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 4b1403478d..668c0a1c92 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -3815,22 +3815,26 @@ void BufferView::draw(frontend::Painter & pain, bool 
paint_caret)
        }
// If a caret has to be painted, mark its text row as dirty to
-       //make sure that it will be repainted on next redraw.
+       // make sure that it will be repainted on next redraw.
        /* FIXME: investigate whether this can be avoided when the cursor did 
not
         * move at all
         */
        if (paint_caret) {
                Cursor cur(d->cursor_);
                while (cur.depth() > 1) {
-                       if (!cur.inTexted())
-                               break;
-                       TextMetrics const & tm = textMetrics(cur.text());
-                       if (d->caret_geometry_.left >= tm.origin().x
-                               && d->caret_geometry_.right <= tm.origin().x + 
tm.dim().width())
-                               break;
+                       if (cur.inTexted()) {
+                               TextMetrics const & tm = 
textMetrics(cur.text());
+                               if (d->caret_geometry_.left >= tm.origin().x
+                                   && d->caret_geometry_.right <= 
tm.origin().x + tm.dim().width())
+                                       break;
+                       }
                        cur.pop();
                }
-               cur.textRow().changed(true);
+               TextMetrics const & tm = textMetrics(cur.text());
+               if (tm.contains(cur.pit())) {
+                       ParagraphMetrics const & pm = tm.parMetrics(cur.pit());
+                       pm.getRow(cur.pos(), cur.boundary()).changed(true);
+               }
        }
  }

--
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to