The code is not ready for situations where some paragraphs that are
not visible have metrics available. This has been made visible by
a4d9315b, which removes a couple of full metrics updates: the screen
was not correctly scrolled after a scrollToCursor() call.
In PararagraphMetrics, some methods are added to be able to handle the
fact that paragraphs have or do not have a position.
In TextMetrics, a new method returns the first visible paragraph.
Finally, in BufferView::updateMetrics, the paragraphs' positions are
reset (in the case where everything is not cleared) and some care is
taken to skip the ones that are not relevant.
The assumption outside of this method is that all the paragraphs that
are in the TextMetrics are visible (we are talking about top-level
TextMetrics here). This could be changed (in order to avoid
recomputing paragraph metrics), but the cost is high in terms of
complexity and it is not clear that the gain in terms of performance
would be important.
When using a back store, it is obviously important to resize it
whenever the buffer view is resized. The new code path added in
527984ed skipped this part, so that the window was wrong when creating
a new window.
Commit 5577e877 introduces forceUpdateBuffer() to delay actual
updatBuffer() calls to a central place.
In Cursor::upDownInText, the updateNeeded flag (which triggers
Update::Force update flag) is set to true when Cursor::checkDepm
returns true. This is fine, except that checkDepm also leads to a
forceBufferUpdate() call.
The logic in the method was such that, when updateNeeded is already
true when entering, forceBufferUpdate() will be called even though
checkDepm did not request it.
Fixes a slight delay with selecting in MergedManual (the manual of
manuals).
The handling of Update::FitCursor traditionnally recomputes all
metrics once or twice. Now that updateMetrics(false) ensures that all
paragraphs that require it have a metrics, we might as well use that.
Take this occasion to move handling of Update::SinglePar earlier,
before the check for Update::ForceDraw.
The missing metrics computation meant that, when loading a file, the
workarea would not be scrolled correctly to show the cursor.
The resizeBufferView does not create an additional metrics
computation, it just triggers it earlier.
This is triggered by selecting part of an equation under Xcb platform
(x11). Indeed, the current selection has to be sent to the X11 server
and BufferView::requestSelection() is called. Eventually
cap::grabSelection() is the function that creates this partial
MathData object.
Fixes ticket #12947.
The code that handles this special macro insertion (in
Cursor::mathMacroClose())) is very weird: it inserts the contents of
the macro _after_ the macro and later, since the macro is 'greedy', it
will eat this contents and put it in its first macro cell.
Does it make sense to you? It does not ake sense to me either. Anyway,
this is the point where one should make sure that the buffer is set.
Fixes ticket #12682.
When debug (-g) is enabled (default when compiling a development
version), the existing -O optimization level is not correct, since
many variables are optimized out when debugging.
Use -Og instead, and condition not on compiling a development version,
but on --enable-debug. This is the same by default, but it more
precise in our case.
Make sure that math insets have a proper buffer. To this end, make the
Buffer* parameter of InsetMath mandatory and fix the compilation
errors that ensue.
In order to ensure that MathData objects have a valid buffer, the
default MathData() constructor is deleted. This means that a buffer
shall be specified for each MathData object created.
This is fairly mechanical, actually. In particular, in most
InsetMathXxx cases, in MathData and in MathParser, the available
buffer_ member is used.
More specific cases:
- lyxfind.cpp takes the buffer from the Cursor
- calls to vector<MathData>::resize take an additional
MathData(buffer_) parameter. There are cases where resize actually
remove cells, and in this case clear() or even erase() have been
used.
- in InsetMathMacroTemplate, the optional parameters of the
constructors cannot be allowed anymore (a default value cannot
depend on another parameter). Therefore there a now two constructors
instead.
- in MathAutoCorrect.cpp, the MathData objects are not bound to a
buffer, so that std::nullptr is used instead.
- in MathExtern, use a buffer when one is specified, std::nulptr
instead.
Set the buffer of contents that is added to a MathData object through
MathData::insert() (both versions)
MathData::push_back()
asArray()
Also in math macros, initialize look_ with the relevant buffer.
This reduces the number of insets hat do not have a proper buffer.
See #13050 for discussion of this issue.