commit 00f855e4ed3c51a92c77ad001fcc9e4e51dbcb75
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Thu Apr 10 13:54:02 2025 +0200
Move fixBiblio to updateBuffer (4/4): the real thing
Now the code that makes sure that there is a bibitem inset in a
paragraph is in updateBuffer instead of TextMetrics::redoParagraph.
Since we are in Buffer, we do not have access to the BufferView's
cursor. This is why it was needed to introduce the
updateCursorsAfterInsertion machinery.
---
src/Buffer.cpp | 18 +++++++++++-------
src/Paragraph.cpp | 3 ---
src/TextMetrics.cpp | 17 -----------------
3 files changed, 11 insertions(+), 27 deletions(-)
diff --git a/src/Buffer.cpp b/src/Buffer.cpp
index 3db3637364..b2cf8ae3fb 100644
--- a/src/Buffer.cpp
+++ b/src/Buffer.cpp
@@ -5424,20 +5424,24 @@ void Buffer::updateBuffer(ParIterator & parit,
UpdateType utype, bool const dele
pit_type const lastpit = parit.lastpit();
bool changed = false;
for ( ; parit.pit() <= lastpit ; ++parit.pit()) {
+ /** FIXME: this function is const, but nevertheless it
+ * modifies the buffer. To be cleaner, one should modify the
+ * buffer in another function, which is actually non-const.
+ * This would however be costly in terms of code duplication.
+ */
// reduce depth if necessary
if (parit->params().depth() > maxdepth) {
- /** FIXME: this function is const, but
- * nevertheless it modifies the buffer. To be
- * cleaner, one should modify the buffer in
- * another function, which is actually
- * non-const. This would however be costly in
- * terms of code duplication.
- */
CursorData(parit).recordUndo();
parit->params().depth(maxdepth);
}
maxdepth = parit->getMaxDepthAfter();
+ // Check whether there are InsetBibItems that need fixing
+ if (parit->brokenBiblio()) {
+ CursorData(parit).recordUndo();
+ parit->fixBiblio(parit);
+ }
+
if (utype == OutputUpdate) {
// track the active counters
// we have to do this for the master buffer, since the
local
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 9a028291d4..234ce3fb4b 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -4690,9 +4690,6 @@ void Paragraph::fixBiblio(DocIterator & dit)
changedit.pos() = 0;
dit.buffer()->updateCursorsAfterInsertion(changedit);
}
-
- // This is needed to get the counters right (#8499)
- dit.buffer()->updateBuffer();
}
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index 6ef1a565a4..67229c6cf3 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -499,23 +499,6 @@ bool TextMetrics::redoParagraph(pit_type const pit, bool
const align_rows)
Buffer & buffer = bv_->buffer();
bool changed = false;
- // Check whether there are InsetBibItems that need fixing
- // FIXME: This check ought to be done somewhere else. It is the reason
- // why text_ is not const. But then, where else to do it?
- // Well, how can you end up with either (a) a biblio environment that
- // has no InsetBibitem, (b) a biblio environment with more than one
- // InsetBibitem or (c) a paragraph that has a bib item but is no biblio
- // environment? I think the answer is: when paragraphs are merged;
- // when layout is set; when material is pasted.
- if (par.brokenBiblio()) {
- Cursor & cur = bv_->cursor();
- // In some cases, we do not know how to record undo
- if (&cur.inset() == &text_->inset())
- cur.recordUndo(pit, pit);
-
- par.fixBiblio(cur);
- }
-
// Optimisation: this is used in the next two loops
// so better to calculate that once here.
int const right_margin = rightMargin(pm);
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs