]> git.lyx.org Git - features.git/commitdiff
When splitting a bufferview, keep the scrollbar position
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 4 Sep 2023 09:26:55 +0000 (11:26 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 5 Sep 2023 12:33:18 +0000 (14:33 +0200)
This is actually better thean making sure that the cursor is visible.

Fixes bug #12689.

src/BufferView.cpp
src/BufferView.h
src/frontends/qt/GuiView.cpp

index 879beb0087271df2a706862db09356cc7b2c0e40..ad534eae2842500319bc7b796d24c59157307ea5 100644 (file)
@@ -337,6 +337,14 @@ BufferView::~BufferView()
 }
 
 
+void BufferView::copySettingsFrom(BufferView const & bv)
+{
+       setCursor(bv.cursor());
+       d->anchor_pit_ = bv.d->anchor_pit_;
+       d->anchor_ypos_ = bv.d->anchor_ypos_;
+}
+
+
 int BufferView::defaultMargin() const
 {
        // The value used to be hardcoded to 10
index f816eda0c5f7c2730c8fe0c59e96424a304fe0fe..d239fdd3607b2c1d86081a99e70f9655e7f8ba48 100644 (file)
@@ -108,6 +108,9 @@ public:
        Buffer & buffer();
        Buffer const & buffer() const;
 
+       /// Copy cursor and vertical offset information from \c bv
+       void copySettingsFrom(BufferView const & bv);
+
        ///
        void setFullScreen(bool full_screen) { full_screen_ = full_screen; }
 
index c9a9ff87fcc07b80ad763ef983cd61f97bef020e..3723afec1f6a307e9ee4ff1f50e7c5f24313ee15 100644 (file)
@@ -4879,8 +4879,8 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        TabWorkArea * twa = addTabWorkArea();
                        GuiWorkArea * wa = twa->addWorkArea(*doc_buffer, *this);
 
-                       wa->bufferView().setCursor(bv->cursor());
-                       dr.screenUpdate(Update::ForceAll | Update::FitCursor);
+                       wa->bufferView().copySettingsFrom(*bv);
+                       dr.screenUpdate(Update::ForceAll);
                        setCurrentWorkArea(wa);
                        break;
                }