]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.C
fix crash when collapsing ert with cursor inside
[lyx.git] / src / BufferView.C
index ecc66f0e05e8c4a1aee8cb3c8ced8de450c16f7d..918d7a3e33c556cc94bdc93fbf9b17fc578a8bd7 100644 (file)
@@ -275,9 +275,7 @@ void BufferView::gotoLabel(string const & label)
                vector<string> labels;
                it->getLabelList(*buffer(), labels);
                if (find(labels.begin(),labels.end(),label) != labels.end()) {
-                       cursor().clearSelection();
-                       text()->setCursor(cursor(), it.pit(), it.pos());
-                       cursor().resetAnchor();
+                       setCursor(it);
                        update();
                        return;
                }
@@ -324,23 +322,23 @@ LyXText * BufferView::text() const
 }
 
 
-void BufferView::setCursor(ParIterator const & par, lyx::pos_type pos)
+void BufferView::setCursor(DocIterator const & dit)
 {
-       for (int i = 0, n = par.size(); i < n; ++i)
-               par[i].inset().edit(cursor(), true);
+       size_t const n = dit.depth();
+       for (size_t i = 0; i < n; ++i)
+               dit[i].inset().edit(cursor(), true);
 
-       cursor().setCursor(makeDocIterator(par, pos));
+       cursor().setCursor(dit);
        cursor().selection() = false;
 }
 
+
 void BufferView::putSelectionAt(DocIterator const & cur,
                                int length, bool backwards)
 {
-       ParIterator par(cur);
-
        cursor().clearSelection();
 
-       setCursor(par, cur.pos());
+       setCursor(cur);
 
        if (length) {
                if (backwards) {