Now that SingleParUpdate does not always lead to a full screen update
when the height of the paragraph changes (see new behavior of
updateMatrics(bool)), it is necessary to make sure that the grey area
below the main page is always repainted.
When a buffer is reloaded, its content may remain the same, but the
memory allocation is new, so that the inset pointers in cursors are
now wrong. This requires to sanitize the cursors held by the buffer
views.
Before the biginset branch, some full metrics computation call that is
now removed probably did that as a side effect. Now we have to be more
precise.
To this effect, introduce WorkAreaManager::sanitizeCursors() and use
it in Buffer::reload().
- avoid copying of configure.log
- avoid copying of chkconfig.ltx
There is a report of a hang on first start of LyX with new major release.
The removal of the chkconfig.ltx (leftover from early LyX versions) fixed the issue.
When the width of the window did not change, computing full metrics is
not necessary in BufferView::resize(), but it is better to redraw the
screen (especially with Wayland).
Typical use cases are when using M-x to open the minibuffer or going
in and out of an equation (which shows/hides the math toolbars).
See description here:
https://marc.info/?l=lyx-devel&m=171243435229412&w=2
cutSelectionHelper did not request a metrics update when the selection
was inner to a paragraph. The new code is better, but it was not
necessary before the biginset branch because of a full metrics
computation that hid this missing case.
Annotate function LFUN_FINISHED_xxx to indicate that they do not
require a full metrics computation.
Remove an "optimization" that meant that when the cursor changed
inset, a full metrics computation was requested.
Part of bug #12297
When entering/leaving a math hull inset, a Update::Force flag was set,
in case the metrics of the inset would change because of a switch
between normal and preview representation.
When entering the inset, this code is now used only when the inset was
in preview mode.
In both cases, Update::Force is replaced with Update::SinglePar.
This requites in Text::dispatch to honor Update::SinglePar when it has
been set by some lfun, even when singleparupdate is false.
Part of bug #12297.
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.
The number of metrics updates when loading file and showing it in a
new work area is unreasonable.
The first avoided call to updateMetrics() was an explicit resize in
BufferView::init(). Instead, an assertion is suppressed by exiting
early BufferView::processUpdateFlags() when BufferView::ready()
returns false. This is a new method introduced to factor in some
existing tests.
Two other metrics computations are avoided by setting the enclosing
View object busy() while creating the new tab. To make this work
properly, GuiWorkArea::scheduleRedraw has to return early in this
case.
When saving an unnamed document or invoking "Save as...", call
setBusy(false) earlier so that repainting occurs correctly.
Fixes bug #12976.
With the branch-test.lyx file from #12297, loading takes forever when
previews are activated. This is because each preview element causes a
full screen metrics recomputation.
This commit just skips these calls and only does one when all previews
have been obtained. As a result, computing the previews takes 1 second
instead of 25 seconds on branch-test.lyx.
Part of bug #12297.
The most visible part of this commit is the move of part of
BufferView::updateMetrics to a new TextMetrics::updateMetrics. This
new method makes sure that metrics are known for all visible paragraphs
(starting from anchor), and that the positions of the paragraphs have
been recorded.
This method is called up to 3 times in BufferView::updateMetrics:
* unconditionally, to update all visible metrics,
* then, if the bottom of the document is visible and too high, after
updating the anchor ypos,
* and similarly if the top of the document is visible and too low.
This fixes for example the case where one jumps to Section 5.3 at the
end of Tutorial and 'scroll_below_document' is false.
Some now redundant code is removed from BufferView::scrollToCursor.
The anchor-setting code in BufferView::draw is not clearly useful, but
left here just in case. It generates a debug warning, though.
Part of bug #12297.
Replace flag parameter for updateMetrics() by a `force' boolean. When
it is false, the method keeps the metrics of paragraphs that are still
visible in WorkArea instead of computing everything afresh. All it has
to do is update their positions.
Add code to updateMetrics() to update the value of the anchor pit/ypos
(similar to the one in draw()).
Update processUpdateFlags() to use this when update flag is ForceDraw.
Modify scrollDocView() to just change the anchor paragraph position
when the scrolling operation would re-use some of the existing
paragraphs.
The time needed to update the metrics when scrolling with mouse in the
branch-test.lyx document is now divided by 20!
Part of bug #12297.
This can make a big difference for a very large branch that contains
lots of equations.
This is complementary to the previous patch, since instead of reducing
the number of calls to updatePosCache, we make it faster.
In the same test of scrolling with mouse wheel through the
branch-test.lyx document, one finds a 23% improvement for
BufferView::updateMetrics().
Part of bug #12297.
The setting of insets positions was done twice in updateMetrics.
When one of the paragraph is a huge branch, this can be very expensive.
This leads to a 17% improvement on updateMetrics time on a scrolling test.
Part of bug #12297
The idea of single par update is to try to re-break only the paragraph
containing the cursor (if this paragraph contains insets etc.,
re-breaking will recursively descend).
The existing single paragraph update mechanism was tailored to work
only at top level. Indeed changing a paragraph nested into an inset may
lead to larger changes.
This commit tries a rather naive approach that seems to work well: we
need a full redraw if either
1/ the height has changed
or
2/ the width has changed and it was equal to the text metrics width;
the goal is to catch the case of a one-row inset that grows with
its contents, but optimize the case of typing in a short paragraph
part of a larger inset.
NOTE: if only the height has changed, then it should be
possible to update all metrics at minimal cost. However,
since this is risky, we do not try that right now.
Part of bug #12297.
if the undo element we want to add only changes stuff that was already
modified by the previous one on undo stack (in the same group), then
skip it. There is nothing to gain in adding it to the stack.
The typical use case is when doing a search and replace in a large
document that does many replacements in each paragraph. In this case,
the same paragraph would be stored repeatedly.
Fixes bug #12564.