From 9cf5358d7da72ee2b14c8000f540a47c4ab44a40 Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Sun, 15 Apr 2007 04:50:42 +0000 Subject: [PATCH] lastFilePos: save bottom level pit and pos git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17814 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 6 +++++- src/frontends/qt4/GuiView.C | 5 +++-- src/lyxfunc.C | 3 --- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 0394673d7c..cee8bd7c11 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -168,8 +168,12 @@ void BufferView::setBuffer(Buffer * b) const_cast(bm).setPos(new_pit, new_id); } // 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(FileName(buffer_->fileName()), - boost::tie(cursor_.pit(), cursor_.pos()) ); + boost::tie(cursor_.bottom().pit(), cursor_.bottom().pos()) ); } // If we're quitting lyx, don't bother updating stuff diff --git a/src/frontends/qt4/GuiView.C b/src/frontends/qt4/GuiView.C index f56e4845e6..2e82718468 100644 --- a/src/frontends/qt4/GuiView.C +++ b/src/frontends/qt4/GuiView.C @@ -260,10 +260,11 @@ void GuiView::closeEvent(QCloseEvent * close_event) if (view()->buffer()) { // save cursor position for opened files to .lyx/session + // only bottom (whole doc) level pit and pos is saved. LyX::ref().session().lastFilePos().save( FileName(buffer()->fileName()), - boost::tie(view()->cursor().pit(), - view()->cursor().pos())); + boost::tie(view()->cursor().bottom().pit(), + view()->cursor().bottom().pos())); } // this is the place where we leave the frontend. diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 2c68a83f10..e1cf479282 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -2040,9 +2040,6 @@ void LyXFunc::doImport(string const & argument) void LyXFunc::closeBuffer() { - // save current cursor position - LyX::ref().session().lastFilePos().save(FileName(lyx_view_->buffer()->fileName()), - boost::tie(view()->cursor().pit(), view()->cursor().pos()) ); // goto bookmark to update bookmark pit. for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i) gotoBookmark(i+1, false, false);