commit 1befe82fafc10a2e4aec658677808d23eea3bd9b
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.
    
    (cherry picked from commit 8cfe8d1855250086a50d874072d3629c6016f8cb)
---
 src/BufferView.cpp | 20 ++++++++++++--------
 status.24x         |  3 ++-
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 8194271d29..ac569a672c 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -3822,22 +3822,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);
+               }
        }
 }
 
diff --git a/status.24x b/status.24x
index cc1119dfc3..e6dad8ef83 100644
--- a/status.24x
+++ b/status.24x
@@ -80,9 +80,10 @@ What's new
 
 - Fix crash in batch LyX when ui_style is set (bug 13141).
 
-
 - Rebuild toolbars on runtime mode switch on Linux.
 
+- Fix an assertion when image previews are loaded.
+
 
 * INTERNALS
 
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to