]> git.lyx.org Git - lyx.git/commitdiff
* BufferView.C (mouseSetCursor): if the cursor was in an empty
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 17 Jan 2007 15:32:43 +0000 (15:32 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Wed, 17 Jan 2007 15:32:43 +0000 (15:32 +0000)
script inset and the new position is in the nucleus of the inset,
notifyCursorLeaves will kill the script inset itself. So we check
all the elements of the cursor to make sure that they are correct
(bug 2933).

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16729 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView.C

index a9ec2eb305cab785ed87bcf0086121e3dbe6d2c7..2643659f94f988e6925a134c82111f8215423974 100644 (file)
@@ -1278,7 +1278,24 @@ bool BufferView::mouseSetCursor(LCursor & cur)
        if (!badcursor && cursor_.inTexted())
                checkDepm(cur, cursor_);
 
-       cursor_ = cur;
+       // if the cursor was in an empty script inset and the new
+       // position is in the nucleus of the inset, notifyCursorLeaves
+       // will kill the script inset itself. So we check all the
+       // elements of the cursor to make sure that they are correct.
+       // For an example, see bug 2933: 
+       // http://bugzilla.lyx.org/show_bug.cgi?id=2933
+       // The code below could maybe be moved to a DocIterator method.
+       //lyxerr << "cur before " << cur <<std::endl;
+       DocIterator dit(cur.inset());
+       dit.push_back(cur.bottom());
+       size_t i = 1;
+       while (i < cur.depth() && dit.nextInset() == &cur[i].inset()) {
+               dit.push_back(cur[i]);
+               ++i;
+       }
+       //lyxerr << "5 cur after" << dit <<std::endl;
+
+       cursor_.setCursor(dit);
        cursor_.clearSelection();
        // remember new position.
        cursor_.setTargetX();