Hi all,

This patch solves bug 4733.

I added "buffer_view_->scrollToCursor();" to GuiWorkArea::resizeBufferView().

The rest is mambo-jambo to prevent a repaint.

Comments?

Vincent
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index fbe30f1..815fb2f 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -801,10 +801,23 @@ void BufferView::showCursor()
 
 void BufferView::showCursor(DocIterator const & dit, bool recenter)
 {
+       if (scrollToCursor(dit, recenter))
+               buffer_.changed();
+}
+
+
+void BufferView::scrollToCursor()
+{
+       scrollToCursor(d->cursor_, false);
+}
+
+
+bool BufferView::scrollToCursor(DocIterator const & dit, bool recenter)
+{
        // We are not properly started yet, delay until resizing is
        // done.
        if (height_ == 0)
-               return;
+               return false;
 
        LYXERR(Debug::SCROLLING, "recentering!");
 
@@ -845,9 +858,9 @@ void BufferView::showCursor(DocIterator const & dit, bool 
recenter)
                // else, nothing to do, the cursor is already visible so we 
just return.
                if (scrolled != 0) {
                        updateMetrics();
-                       buffer_.changed();
+                       return true;
                }
-               return;
+               return false;
        }
 
        // fix inline completion position
@@ -875,7 +888,7 @@ void BufferView::showCursor(DocIterator const & dit, bool 
recenter)
                d->anchor_ypos_ = defaultRowHeight() * 2;
 
        updateMetrics();
-       buffer_.changed();
+       return true;
 }
 
 
diff --git a/src/BufferView.h b/src/BufferView.h
index 9335a85..fcf5854 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -158,6 +158,11 @@ public:
        /// if needed.
        /// \param recenter Whether the cursor should be centered on screen
        void showCursor(DocIterator const & dit, bool recenter = false);
+       /// Scroll to the cursor.
+       void scrollToCursor();
+       /// Scroll to the cursor.
+       /// \param recenter Whether the cursor should be centered on screen
+       bool scrollToCursor(DocIterator const & dit, bool recenter);
        /// LFUN_SCROLL Helper.
        void lfunScroll(FuncRequest const & cmd);
        /// scroll down document by the given number of pixels.
diff --git a/src/frontends/qt4/GuiWorkArea.cpp 
b/src/frontends/qt4/GuiWorkArea.cpp
index f8014e7..3823401 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -518,6 +518,7 @@ void GuiWorkArea::resizeBufferView()
        // We are already inside a paint event.
        lyx_view_->setBusy(true);
        buffer_view_->resize(viewport()->width(), viewport()->height());
+       buffer_view_->scrollToCursor();
        updateScreen();
 
        // Update scrollbars which might have changed due different
diff --git a/src/frontends/qt4/GuiWorkArea.h b/src/frontends/qt4/GuiWorkArea.h

Reply via email to