]> git.lyx.org Git - features.git/commitdiff
* Text3.cpp:
authorJürgen Spitzmüller <spitz@lyx.org>
Mon, 22 Dec 2008 10:24:43 +0000 (10:24 +0000)
committerJürgen Spitzmüller <spitz@lyx.org>
Mon, 22 Dec 2008 10:24:43 +0000 (10:24 +0000)
- enable LFUN_INSET_DISSOLVE for insets at cursor (bug 4985).

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

src/Text3.cpp

index a20b366035bde04e425568982912b714b06d0848..699482171a52b1fb28d4c6a52b82a3256d148f6a 100644 (file)
@@ -897,9 +897,29 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
-       case LFUN_INSET_DISSOLVE:
-               needsUpdate |= dissolveInset(cur);
+       case LFUN_INSET_DISSOLVE: {
+               // first, try if there's an inset at cursor
+               // FIXME: this first part should be moved to
+               // a LFUN_NEXT_INSET_DISSOLVE, or be called via
+               // some generic "next-inset inset-dissolve"
+               Inset * inset = cur.nextInset();
+               if (inset && inset->isActive()) {
+                       Cursor tmpcur = cur;
+                       tmpcur.pushBackward(*inset);
+                       inset->dispatch(tmpcur, cmd);
+                       if (tmpcur.result().dispatched()) {
+                               cur.dispatched();
+                               break;
+                       }
+               }
+               // if it did not work, try the underlying inset
+               if (dissolveInset(cur)) {
+                       needsUpdate = true;
+                       break;
+               }
+               // if it did not work, do nothing.
                break;
+       }
 
        case LFUN_INSET_SETTINGS: {
                Inset & inset = cur.inset();
@@ -2212,8 +2232,10 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                        enable = cur.inset().lyxCode() == FLEX_CODE
                                 && il.lyxtype() == type;
                } else {
-                       enable = !isMainText(cur.bv().buffer())
-                                && cur.inset().nargs() == 1;
+                       enable = ((!isMainText(cur.bv().buffer())
+                                     && cur.inset().nargs() == 1)
+                                 || (cur.nextInset()
+                                     && cur.nextInset()->nargs() == 1));
                }
                break;