]> git.lyx.org Git - features.git/commitdiff
Fix bug #6033: Initial character sometimes eaten by math-insert
authorEnrico Forestieri <forenr@lyx.org>
Tue, 23 Jun 2009 18:01:31 +0000 (18:01 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 23 Jun 2009 18:01:31 +0000 (18:01 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30246 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyXAction.cpp
src/mathed/InsetMathNest.cpp

index b8120d6c36b5a45347bfa3359236238273a66396..1aa570fa6132e3b21cb33602435040fd8421c42a 100644 (file)
@@ -1529,6 +1529,14 @@ void LyXAction::init()
  * \li Action: Inserts math objects and symbols.
  * \li Syntax: math-insert <ARG>
  * \li Params: <ARG>: Symbol or LaTeX code to be inserted.
+ * \li Notion: When <ARG> is a _single_ math inset with more than one cell
+               (such as "x_y^z" or "\frac{x}{y}"), the content of cell(0) is
+               replaced by the current selection (only works if the selection
+               is in mathed). As an example, if "abc" is selected in mathed,
+               "math-insert \frac{x}{y}" replaces "abc" with "\frac{abc}{y}",
+               and "math-insert x_y^z" replaces "abc" with "abc_y^z".
+               If nothing is selected (or the selection is not in mathed),
+               math-insert works as expected.
  * \endvar
  */
                { LFUN_MATH_INSERT, "math-insert", Noop, Math },
index c6e25b59945d0696f10b15e040631a79c724ae41..cb04af5a7c0c5a3405bda9cfddb017d8c728543b 100644 (file)
@@ -1131,8 +1131,9 @@ void InsetMathNest::doDispatch(Cursor & cur, FuncRequest & cmd)
                else {
                        MathData ar;
                        asArray(cmd.argument(), ar);
-                       if (ar.size() == 1 && ar[0]->asNestInset()
-                                       && ar[0]->asNestInset()->nargs() > 1)
+                       if (cur.selection() && ar.size() == 1
+                           && ar[0]->asNestInset()
+                           && ar[0]->asNestInset()->nargs() > 1)
                                handleNest(cur, ar[0]);
                        else
                                cur.niceInsert(cmd.argument());