]> git.lyx.org Git - lyx.git/commitdiff
Fix Bug3171: update bookmark after saveCursor
authorBo Peng <bpeng@lyx.org>
Sun, 28 Jan 2007 21:12:33 +0000 (21:12 +0000)
committerBo Peng <bpeng@lyx.org>
Sun, 28 Jan 2007 21:12:33 +0000 (21:12 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16919 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C
src/lyxfunc.C

index 8c3abfb7b84b47f1e179f673753d2950354018a3..acd74c38f083aeb6f52163419946a5911266d72b 100644 (file)
@@ -155,6 +155,19 @@ void BufferView::setBuffer(Buffer * b)
                // to this buffer later on.
                buffer_->saveCursor(cursor_.selectionBegin(),
                                    cursor_.selectionEnd());
+               // update bookmark pit of the current buffer before switch
+               for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i) {
+                       BookmarksSection::Bookmark const & bm = LyX::ref().session().bookmarks().bookmark(i);
+                       if (buffer()->fileName() != bm.filename.absFilename())
+                               continue;
+                       // if par_id or pit has been changed, reset par_pit and par_id
+                       // see http://bugzilla.lyx.org/show_bug.cgi?id=3092
+                       pit_type new_pit;
+                       int new_id;
+                       boost::tie(new_pit, new_id) = moveToPosition(bm.par_pit, bm.par_id, bm.par_pos);
+                       if (bm.par_pit != new_pit || bm.par_id != new_id)
+                               const_cast<BookmarksSection::Bookmark &>(bm).setPos(new_pit, new_id);
+               }
                // current buffer is going to be switched-off, save cursor pos
                LyX::ref().session().lastFilePos().save(FileName(buffer_->fileName()),
                        boost::tie(cursor_.pit(), cursor_.pos()) );
index adcf1ce862c5dcb2746d99c6855a12756e65e3e1..369186ecdcd30356d61b3d03d11661dc3f9b58c1 100644 (file)
@@ -1165,9 +1165,6 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
                // --- buffers ----------------------------------------
                case LFUN_BUFFER_SWITCH:
                        BOOST_ASSERT(lyx_view_);
-                       // update bookmark pit of the current buffer before switch
-                       for (size_t i = 0; i < LyX::ref().session().bookmarks().size(); ++i)
-                               gotoBookmark(i+1, false, false);                        
                        lyx_view_->setBuffer(theBufferList().getBuffer(argument));
                        break;