commit cb7094696095236b9a7133f41901e90aee767544
Author: Enrico Forestieri <[email protected]>
Date:   Sat Sep 10 13:36:45 2016 +0200

    Fix bug #9616
---
 src/Encoding.cpp             |   10 ++++++++++
 src/Encoding.h               |    6 ++++++
 src/mathed/InsetMathNest.cpp |    2 +-
 3 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/src/Encoding.cpp b/src/Encoding.cpp
index 73edc84..acb91f6 100644
--- a/src/Encoding.cpp
+++ b/src/Encoding.cpp
@@ -601,6 +601,16 @@ bool Encodings::isMathAlpha(char_type c)
 }
 
 
+bool Encodings::isUnicodeTextOnly(char_type c)
+{
+       if (isASCII(c) || isMathAlpha(c))
+               return false;
+
+       CharInfoMap::const_iterator const it = unicodesymbols.find(c);
+       return it == unicodesymbols.end() || it->second.mathcommand().empty();
+}
+
+
 Encoding const *
 Encodings::fromLyXName(string const & name, bool allowUnsafe) const
 {
diff --git a/src/Encoding.h b/src/Encoding.h
index 5e289ca..0f6e8ff 100644
--- a/src/Encoding.h
+++ b/src/Encoding.h
@@ -287,6 +287,12 @@ public:
         */
        static bool isMathAlpha(char_type c);
        /**
+        * Do we have to wrap in \text this character when in mathmode?
+        * This is true if \p c is not ascii and the "mathalpha" flag is not
+        * set and a mathcommand is not defined in the unicodesymbols file.
+        */
+       static bool isUnicodeTextOnly(char_type c);
+       /**
         * Register \p c as a mathmode command.
         */
        static void addMathCmd(char_type c) { mathcmd.insert(c); }
diff --git a/src/mathed/InsetMathNest.cpp b/src/mathed/InsetMathNest.cpp
index 223e31a..4216145 100644
--- a/src/mathed/InsetMathNest.cpp
+++ b/src/mathed/InsetMathNest.cpp
@@ -1856,7 +1856,7 @@ bool InsetMathNest::interpretChar(Cursor & cur, char_type 
const c)
                        cur.niceInsert(createInsetMath("sim", buf));
                        return true;
                }
-               if (currentMode() == InsetMath::MATH_MODE && 
!isAsciiOrMathAlpha(c)) {
+               if (currentMode() == InsetMath::MATH_MODE && 
Encodings::isUnicodeTextOnly(c)) {
                        MathAtom at = createInsetMath("text", buf);
                        at.nucleus()->cell(0).push_back(MathAtom(new 
InsetMathChar(c)));
                        cur.niceInsert(at);

Reply via email to