When splitting a bufferview, keep the scrollbar position

This is actually better thean making sure that the cursor is visible.

Fixes bug #12689.
This commit is contained in:
Jean-Marc Lasgouttes 2023-09-04 11:26:55 +02:00
parent 375bb32a3d
commit 100e759f17
3 changed files with 13 additions and 2 deletions

View 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

View 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; }

View 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;
}