]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.C
Fix bug 2474; partial fix for 1777. Added last_reference_ member to QRef class and...
[lyx.git] / src / BufferView.C
index 09e0010491faaac0ae168434c3bee6d5bca56d52..2c4b7a36b0317d86f295866b16dd9cb2b5751064 100644 (file)
@@ -357,7 +357,8 @@ bool BufferView::update(Update::flags flags)
        LYXERR(Debug::WORKAREA) << "BufferView::update" << std::endl;
 
        // Update macro store
-       buffer_->buildMacros();
+       if (!(cursor().inMathed() && cursor().inMacroMode()))
+               buffer_->buildMacros();
 
        // Now do the first drawing step if needed. This consists on updating
        // the CoordCache in updateMetrics().
@@ -581,7 +582,17 @@ boost::tuple<pit_type, pos_type, int> BufferView::moveToPosition(pit_type bottom
        if (top_id > 0) {
                ParIterator par = buffer_->getParFromID(top_id);
                if (par != buffer_->par_iterator_end()) {
-                       setCursor(makeDocIterator(par, min(par->size(), top_pos)));
+                       DocIterator dit = makeDocIterator(par, min(par->size(), top_pos));
+                       // Some slices of the iterator may not be reachable (e.g. closed collapsable inset)
+                       // so the dociterator may need to be shortened. Otherwise, setCursor may
+                       // crash lyx when the cursor can not be set to these insets.
+                       size_t const n = dit.depth();
+                       for (size_t i = 0; i < n; ++i)
+                               if (dit[i].inset().editable() != InsetBase::HIGHLY_EDITABLE) {
+                                       dit.resize(i);
+                                       break;
+                               }
+                       setCursor(dit);
                        // Note: return bottom (document) level pit.
                        return boost::make_tuple(cursor_.bottom().pit(), cursor_.bottom().pos(), top_id);
                }