]> git.lyx.org Git - features.git/commitdiff
lastFilePos: save bottom level pit and pos
authorBo Peng <bpeng@lyx.org>
Sun, 15 Apr 2007 04:50:42 +0000 (04:50 +0000)
committerBo Peng <bpeng@lyx.org>
Sun, 15 Apr 2007 04:50:42 +0000 (04:50 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17814 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/frontends/qt4/GuiView.C
src/lyxfunc.C

index 0394673d7ca60b5c9871cdced20648cb1b2e420a..cee8bd7c1197a8c31e34afaa53a9d07976e69879 100644 (file)
@@ -168,8 +168,12 @@ void BufferView::setBuffer(Buffer * b)
                                const_cast<BookmarksSection::Bookmark &>(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
index f56e4845e60fb3027e243c8eca0c2632319ded86..2e827184685995cc4dabc3bf8177f16a3240ae25 100644 (file)
@@ -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.
index 2c68a83f10a081acedb98354156c57812d62eac4..e1cf47928231ee2fed01b2585d28c7272450276f 100644 (file)
@@ -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);