diff --git a/src/BufferView.cpp b/src/BufferView.cpp index b7776050cd..5d41d1b162 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -142,6 +142,14 @@ BufferView::BufferView(Buffer & buf) BufferView::~BufferView() { + // current buffer is going to be switched-off, save cursor pos + // Ideally, the whole cursor stack should be saved, but session + // currently can only handle bottom (whole document) level pit and pos. + // That is to say, if a cursor is in a nested inset, it will be + // restore to the left of the top level inset. + LyX::ref().session().lastFilePos().save( + support::FileName(buffer_.fileName()), + boost::tie(cursor_.bottom().pit(), cursor_.bottom().pos()) ); } diff --git a/src/frontends/WorkArea.cpp b/src/frontends/WorkArea.cpp index 037831ab08..d27816a676 100644 --- a/src/frontends/WorkArea.cpp +++ b/src/frontends/WorkArea.cpp @@ -29,7 +29,6 @@ #include "Font.h" #include "FuncRequest.h" #include "Language.h" -#include "LyX.h" #include "LyXFunc.h" #include "LyXRC.h" #include "MetricsInfo.h" @@ -90,16 +89,6 @@ WorkArea::~WorkArea() bufferChangedConnection_.disconnect(); bufferClosingConnection_.disconnect(); - // current buffer is going to be switched-off, save cursor pos - // Ideally, the whole cursor stack should be saved, but session - // currently can only handle bottom (whole document) level pit and pos. - // That is to say, if a cursor is in a nested inset, it will be - // restore to the left of the top level inset. - Cursor & cur = buffer_view_->cursor(); - LyX::ref().session().lastFilePos().save( - support::FileName(buffer_view_->buffer().fileName()), - boost::tie(cur.bottom().pit(), cur.bottom().pos()) ); - delete buffer_view_; }