Asger Ottar Alstrup wrote:
Maybe the problem was introduced in revision 14861 by baum, where he converted lfun arguments to docstring. Line 705 (was line 695 in 14860) was changed from only calling interpret with the first character to be called with all characters.

I'm trying to call interpret with just one character again, to see if that helps.

Yes, that was the problem. It's tricky: There are two different interpret functions - one taking a character and another taking a string. Baum changed it to take a string, and then it broke because it called the wrong method.

Patch attached, will commit shortly.

Regards,
Asger
Index: converter.C
===================================================================
--- converter.C (revision 15373)
+++ converter.C (working copy)
@@ -322,7 +322,7 @@
                Alert::error(_("Cannot convert file"),
                             bformat(_("No information for converting %1$s "
                                                    "format files to %2$s.\n"
-                                                   "Define a convertor in the 
preferences."),
+                                                   "Define a converter in the 
preferences."),
                                                        
lyx::from_ascii(from_format), lyx::from_ascii(to_format)));
                return false;
        }
Index: cursor.C
===================================================================
--- cursor.C    (revision 15373)
+++ cursor.C    (working copy)
@@ -864,7 +864,7 @@
                lyxerr << "can't enter recursive macro" << endl;
 
        InsetMathNest * const in = inset().asInsetMath()->asNestInset();
-       if (in && in->interpret(*this, s))
+       if (in && in->interpretString(*this, s))
                return true;
        plainInsert(createInsetMath(name));
        return true;
Index: mathed/InsetMathNest.C
===================================================================
--- mathed/InsetMathNest.C      (revision 15373)
+++ mathed/InsetMathNest.C      (working copy)
@@ -675,7 +675,7 @@
                if (cmd.argument().size() != 1) {
                        recordUndo(cur);
                        string const arg = lyx::to_utf8(cmd.argument());
-                       if (!interpret(cur, arg))
+                       if (!interpretString(cur, arg))
                                cur.insert(arg);
                        break;
                }
@@ -705,9 +705,12 @@
                // FIXME: Change to
                // } else if (!interpret(cur, cmd.argument()[0])) {
                // when interpret accepts UCS4 characters
-               } else if (!interpret(cur, lyx::to_utf8(cmd.argument()))) {
-                       cmd = FuncRequest(LFUN_FINISHED_RIGHT);
-                       cur.undispatched();
+               } else {
+                       std::string arg0 = lyx::to_utf8(docstring(1, 
cmd.argument()[0]));
+                       if (!interpretChar(cur, arg0[0])) {
+                               cmd = FuncRequest(LFUN_FINISHED_RIGHT);
+                               cur.undispatched();
+                       }
                }
                break;
 
@@ -913,19 +916,19 @@
        case LFUN_ERT_INSERT:
                // interpret this as if a backslash was typed
                recordUndo(cur, Undo::ATOMIC);
-               interpret(cur, '\\');
+               interpretChar(cur, '\\');
                break;
 
        case LFUN_MATH_SUBSCRIPT:
                // interpret this as if a _ was typed
                recordUndo(cur, Undo::ATOMIC);
-               interpret(cur, '_');
+               interpretChar(cur, '_');
                break;
 
        case LFUN_MATH_SUPERSCRIPT:
                // interpret this as if a ^ was typed
                recordUndo(cur, Undo::ATOMIC);
-               interpret(cur, '^');
+               interpretChar(cur, '^');
                break;
 
 // FIXME: We probably should swap parts of "math-insert" and "self-insert"
@@ -933,9 +936,10 @@
 // math-insert only handles special math things like "matrix".
        case LFUN_MATH_INSERT: {
                recordUndo(cur, Undo::ATOMIC);
-               if (cmd.argument() == "^" || cmd.argument() == "_")
-                       interpret(cur, cmd.argument()[0]);
-               else
+               if (cmd.argument() == "^" || cmd.argument() == "_") {
+                       std::string arg0 = lyx::to_utf8(docstring(1, 
cmd.argument()[0]));
+                       interpretChar(cur, arg0[0]);
+               } else
                        cur.niceInsert(lyx::to_utf8(cmd.argument()));
                break;
                }
@@ -1162,7 +1166,7 @@
 }
 
 
-bool InsetMathNest::interpret(LCursor & cur, char c)
+bool InsetMathNest::interpretChar(LCursor & cur, char c)
 {
        //lyxerr << "interpret 2: '" << c << "'" << endl;
        string save_selection;
@@ -1249,7 +1253,7 @@
                if (c == '{')
                        cur.niceInsert(MathAtom(new InsetMathBrace));
                else if (c != ' ')
-                       interpret(cur, c);
+                       interpretChar(cur, c);
                return true;
        }
 
@@ -1338,7 +1342,7 @@
 }
 
 
-bool InsetMathNest::interpret(LCursor & cur, string const & str)
+bool InsetMathNest::interpretString(LCursor & cur, string const & str)
 {
        // Create a InsetMathBig from cur.cell()[cur.pos() - 1] and t if
        // possible
@@ -1370,7 +1374,7 @@
                if (up)
                        cur.niceInsert(createInsetMath("mathcircumflex"));
                else
-                       interpret(cur, '_');
+                       interpretChar(cur, '_');
                return true;
        }
 
Index: mathed/InsetMathNest.h
===================================================================
--- mathed/InsetMathNest.h      (revision 15373)
+++ mathed/InsetMathNest.h      (working copy)
@@ -110,7 +110,7 @@
 
        /// interpret \p c and insert the result at the current position of
        /// of \p cur. Return whether the cursor should stay in the formula.
-       bool interpret(LCursor & cur, char c);
+       bool interpretChar(LCursor & cur, char c);
        ///
        bool script(LCursor & cur, bool,
                std::string const & save_selection = std::string());
@@ -119,7 +119,7 @@
        /// interpret \p str and insert the result at the current position of
        /// \p cur if it is something known. Return whether \p cur was
        /// inserted.
-       bool interpret(LCursor & cur, std::string const & str);
+       bool interpretString(LCursor & cur, std::string const & str);
 
 private:
        /// lfun handler

Reply via email to