Martin Vermeer wrote:
> I propose to put the attached summarizing patch in, and test and profile
> again.

My comments are those of someone who is entirely ignorant of this part of
the code, so please take them with a pinch of salt. Well meaning
interference :)

Angus


Why the two if statements rather than && ?
Index: BufferView_pimpl.C
-               if ((flags & Update::FitCursor) && fitCursor()) {
-                       forceupdate = true;
-                       vi = metrics(flags & Update::SinglePar);
+               if (flags & Update::FitCursor) {
+                       if (fitCursor()) {
+                               forceupdate = true;
+                               vi = metrics();
+                       }


I think you should comment the code more so that your learning curve
doesn't have to be repeated. How about:
+       // Rebreak the paragraph, but only if the "pit" points to
+       // the bottommost iterator in the cursor stack.
+       // Ie, the paragraph containing all nested insets.
Or something :)
        // Rebreak anchor par
-       text->redoParagraph(pit);
-       int y0 = text->getPar(pit1).ascent() - offset_ref_;
+       if (!singlepar || pit == cursor_[0].pit()) // only rebreak cursor para
+               text->redoParagraph(pit);
+       int y0 = text->getPar(pit).ascent() - offset_ref_;


Why does this need to be inside the loop? Looks to me like "y1" and "y2"
are overwritten on each iteration of the loop and that "y" and "pit" are
available immediately afterwards.
@@ -1379,13 +1377,27 @@ ViewMetricsInfo BufferView::Pimpl::metri
        for (lyx::pit_type pit = pit1; pit <= pit2; ++pit) {
                y += text->getPar(pit).ascent();
                theCoords.parPos()[text][pit] = Point(0, y);
+               if (singlepar && pit == cursor_[0].pit()) {
+                       // collect cursor paragraph y's
+                       y1 = y - text->getPar(pit).ascent();
+                       y2 = y + text->getPar(pit).descent();
+               }
                y += text->getPar(pit).descent();
        }
I *think* that the above becomes,
        lyx::pit_type prevpit = boost::prior(pit);
        if (singlepar && prevpit == cursor_[0].pit()) {
                y1 = y - text->getPar(prevpit).descent();
                y2 = y;
        }


Reply via email to