]> git.lyx.org Git - features.git/commitdiff
Fix crash when putting a float around multiple display maths (bug #7974).
authorJürgen Spitzmüller <spitz@lyx.org>
Sat, 21 Jan 2012 07:02:09 +0000 (07:02 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Sat, 21 Jan 2012 07:02:09 +0000 (07:02 +0000)
This also fixes other float-related bugs, such as this:

* select two floats in two consecutive paragraphs and insert a new float around them
=> the master float's caption is put into the lower subfloat instead of below the subfloats.

In the long term, doInsertInset needs a thorough cleanup.

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

src/Text3.cpp

index 4c1d07bf46720cc8141b32cc79ba8a6034e76647..ce6811452700f437ba63459a2d9806c3a78c539e 100644 (file)
@@ -1670,16 +1670,19 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_FLOAT_INSERT:
        case LFUN_FLOAT_WIDE_INSERT:
        case LFUN_WRAP_INSERT: {
-               // will some text be moved into the inset?
-               bool content = cur.selection();
+               // will some content be moved into the inset?
+               bool const content = cur.selection();
+               // does the content consist of multiple paragraphs?
+               bool const singlepar = (cur.selBegin().pit() == cur.selEnd().pit());
 
                doInsertInset(cur, this, cmd, true, true);
                cur.posForward();
 
-               // If some text is moved into the inset, doInsertInset 
-               // puts the cursor outside the inset. To insert the
-               // caption we put it back into the inset.
-               if (content)
+               // If some single-par content is moved into the inset,
+               // doInsertInset puts the cursor outside the inset.
+               // To insert the caption we put it back into the inset.
+               // FIXME cleanup doInsertInset to avoid such dances!
+               if (content && singlepar)
                        cur.backwardPos();
 
                ParagraphList & pars = cur.text()->paragraphs();