From: Jean-Marc Lasgouttes Date: Mon, 4 Sep 2023 09:26:55 +0000 (+0200) Subject: When splitting a bufferview, keep the scrollbar position X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=100e759f17e8abad66c7923e1737a7f41e8e5ca2;p=features.git When splitting a bufferview, keep the scrollbar position This is actually better thean making sure that the cursor is visible. Fixes bug #12689. --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index 879beb0087..ad534eae28 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -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 diff --git a/src/BufferView.h b/src/BufferView.h index f816eda0c5..d239fdd360 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -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; } diff --git a/src/frontends/qt/GuiView.cpp b/src/frontends/qt/GuiView.cpp index c9a9ff87fc..3723afec1f 100644 --- a/src/frontends/qt/GuiView.cpp +++ b/src/frontends/qt/GuiView.cpp @@ -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; }