]> git.lyx.org Git - lyx.git/commitdiff
Fix bug #6466
authorGuillaume Munch <gadmm@free.fr>
Sun, 23 Aug 2015 09:47:37 +0000 (11:47 +0200)
committerGeorg Baum <baum@lyx.org>
Sun, 23 Aug 2015 09:47:37 +0000 (11:47 +0200)
\{ and \% now correctly use the selection as their argument instead of
erasing it.

src/mathed/InsetMathComment.cpp
src/mathed/InsetMathComment.h
src/mathed/InsetMathNest.cpp

index 096cf38752d80371d7b6941d9ebad25459205e02..ff91991aa86ff0755fb7cb470f0f28e734bbca91 100644 (file)
@@ -26,6 +26,13 @@ InsetMathComment::InsetMathComment(Buffer * buf)
 {}
 
 
+InsetMathComment::InsetMathComment(MathData const & ar)
+       : InsetMathNest(const_cast<Buffer *>(ar.buffer()), 1)
+{
+       cell(0) = ar;
+}
+
+
 InsetMathComment::InsetMathComment(Buffer * buf, docstring const & str)
        : InsetMathNest(buf, 1)
 {
index fa33c630914ec1ff251cf02dbfabfb8126eb6bbe..8cfe1368d7cb01cbf7465b8d096af8776194cdf0 100644 (file)
@@ -25,6 +25,8 @@ public:
        ///
        InsetMathComment(Buffer * buf);
        ///
+       InsetMathComment(MathData const & ar);
+       ///
        explicit InsetMathComment(Buffer * buf, docstring const &);
        ///
        void metrics(MetricsInfo & mi, Dimension & dim) const;
index 6382f1cf84caaf6a3a66798feec4cca04828be67..9081021c5dee57a2cad538319144d3f9b4245df7 100644 (file)
@@ -1657,12 +1657,17 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type const c)
                        } else if (c == '^' && currentMode() == InsetMath::MATH_MODE) {
                                cur.backspace();
                                cur.niceInsert(createInsetMath("mathcircumflex", buf));
-                       } else if (c == '{') {
-                               cur.backspace();
-                               cur.niceInsert(MathAtom(new InsetMathBrace(buf)));
-                       } else if (c == '%') {
+                       } else if (c == '{' || c == '%') {
+                               //using the saved selection as argument
+                               InsetMathUnknown * p = cur.activeMacro();
+                               p->finalize();
+                               MathData sel(cur.buffer());
+                               asArray(p->selection(), sel);
                                cur.backspace();
-                               cur.niceInsert(MathAtom(new InsetMathComment(buf)));
+                               if (c == '{')
+                                       cur.niceInsert(MathAtom(new InsetMathBrace(sel)));
+                               else
+                                       cur.niceInsert(MathAtom(new InsetMathComment(sel)));
                        } else if (c == '#') {
                                LASSERT(cur.activeMacro(), return false);
                                cur.activeMacro()->setName(name + docstring(1, c));