The attached seems to work for that bug, but I haven't tested extensively as I don't use Bibitems myself. Still, the approach seems right, and possible, since the updateBuffer() call is now from one place.

As I mention in the bug report, though, there are some other issues that remain.

Richard

Index: src/frontends/qt4/GuiApplication.cpp
===================================================================
--- src/frontends/qt4/GuiApplication.cpp	(revision 36165)
+++ src/frontends/qt4/GuiApplication.cpp	(working copy)
@@ -1100,9 +1100,16 @@
 
 	BufferView * bv = current_view_->currentBufferView();
 	if (bv) {
-		if (dr.needBufferUpdate()) {
-			bv->cursor().clearBufferUpdate();
-			bv->buffer().updateBuffer();
+		Cursor & cursor = bv->cursor();
+		Buffer & buf = bv->buffer();
+		int const moveCursor = cursor.paragraph().checkBiblio(buf);
+		if (moveCursor > 0)
+			cursor.posForward();
+		else if (moveCursor < 0 && cursor.pos() >= -moveCursor)
+			cursor.posBackward();
+		if (moveCursor != 0 || dr.needBufferUpdate()) {
+			cursor.clearBufferUpdate();
+			buf.updateBuffer();
 		}
 		// BufferView::update() updates the ViewMetricsInfo and
 		// also initializes the position cache for all insets in
Index: src/TextMetrics.cpp
===================================================================
--- src/TextMetrics.cpp	(revision 36165)
+++ src/TextMetrics.cpp	(working copy)
@@ -371,21 +371,6 @@
 	main_text_ = (text_ == &buffer.text());
 	bool changed = false;
 
-	// 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 or (b) a biblio environment with more than one
-	// InsetBibitem? I think the answer is: when paragraphs are merged;
-	// when layout is set; when material is pasted.
-	int const moveCursor = par.checkBiblio(buffer);
-	if (moveCursor > 0)
-		const_cast<Cursor &>(bv_->cursor()).posForward();
-	else if (moveCursor < 0) {
-		Cursor & cursor = const_cast<Cursor &>(bv_->cursor());
-		if (cursor.pos() >= -moveCursor)
-			cursor.posBackward();
-	}
-
 	// Optimisation: this is used in the next two loops
 	// so better to calculate that once here.
 	int const right_margin = rightMargin(pm);

Reply via email to