]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.C
Fix bug 3148: always update the Labels if a DEPM is triggered.
[lyx.git] / src / BufferView.C
index 8c3abfb7b84b47f1e179f673753d2950354018a3..ff3b47924018f876f07d04a52d8774abce6ac1c8 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()) );
@@ -489,6 +502,9 @@ void BufferView::scrollDocView(int value)
 
 void BufferView::setCursorFromScrollbar()
 {
+       if (!buffer_)
+               return;
+
        LyXText & t = buffer_->text();
 
        int const height = 2 * defaultRowHeight();
@@ -1281,6 +1297,8 @@ bool BufferView::checkDepm(LCursor & cur, LCursor & old)
        if (!changed)
                return false;
 
+       updateLabels(*buffer_);
+
        updateMetrics(false);
        buffer_->changed();
        return true;