]> git.lyx.org Git - features.git/commitdiff
Avoid metrics computation on resize when width did not change
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 27 Nov 2023 10:46:52 +0000 (11:46 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 5 Apr 2024 11:06:26 +0000 (13:06 +0200)
Entering a math inset triggers a work area reize because the math
toobars appear automatically. However, by default these toolbars are
at the bottom of the screen and their presence does not change the
typesetting of paragraphs. Therefore it is useful to avoid a call to
updateMetrics() in the case where the width of the work area did not
change.

Part of bug #12297.

src/BufferView.cpp

index 34be8606914e92c0b4111b9caac0520b092dd425..c03f928c4d18ede0a0ee21f28d9e964d40ced0e9 100644 (file)
@@ -2484,14 +2484,16 @@ void BufferView::clearSelection()
 
 void BufferView::resize(int width, int height)
 {
-       // Update from work area
-       width_ = width;
        height_ = height;
+       // Update metrics only if width has changed
+       if (width != width_) {
+               width_ = width;
 
-       // Clear the paragraph height cache.
-       d->par_height_.clear();
-       // Redo the metrics.
-       updateMetrics();
+               // Clear the paragraph height cache.
+               d->par_height_.clear();
+               // Redo the metrics.
+               updateMetrics();
+       }
 }
 
 
@@ -3131,6 +3133,8 @@ void BufferView::updateMetrics(bool force)
        if (!ready())
                return;
 
+       //LYXERR0("updateMetrics " << _v_(force));
+
        Text & buftext = buffer_.text();
        pit_type const lastpit = int(buftext.paragraphs().size()) - 1;