mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Ensure proper mode in mathed
A math-mode command entered in a text-mode environment is wrapped in an ensuremath inset, as well as a text-mode command entered in a math-mode environment is wrapped in a text inset. Who doesn't like the extra insets can always dissolve them and rely on the wrapping performed on export.
This commit is contained in:
parent
b9a47dff4e
commit
324651899e
@ -47,9 +47,11 @@
|
|||||||
|
|
||||||
#include "mathed/InsetMath.h"
|
#include "mathed/InsetMath.h"
|
||||||
#include "mathed/InsetMathBrace.h"
|
#include "mathed/InsetMathBrace.h"
|
||||||
|
#include "mathed/InsetMathEnsureMath.h"
|
||||||
#include "mathed/InsetMathScript.h"
|
#include "mathed/InsetMathScript.h"
|
||||||
#include "mathed/MacroTable.h"
|
#include "mathed/MacroTable.h"
|
||||||
#include "mathed/MathData.h"
|
#include "mathed/MathData.h"
|
||||||
|
#include "mathed/MathFactory.h"
|
||||||
#include "mathed/MathMacro.h"
|
#include "mathed/MathMacro.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -1447,6 +1449,19 @@ bool Cursor::macroModeClose()
|
|||||||
else if (atom.nucleus()->nargs() > 0)
|
else if (atom.nucleus()->nargs() > 0)
|
||||||
atom.nucleus()->cell(0).append(selection);
|
atom.nucleus()->cell(0).append(selection);
|
||||||
|
|
||||||
|
if (in->currentMode() == Inset::TEXT_MODE
|
||||||
|
&& atom.nucleus()->currentMode() == Inset::MATH_MODE) {
|
||||||
|
MathAtom at(new InsetMathEnsureMath(buffer()));
|
||||||
|
at.nucleus()->cell(0).push_back(atom);
|
||||||
|
niceInsert(at);
|
||||||
|
posForward();
|
||||||
|
} else if (in->currentMode() == Inset::MATH_MODE
|
||||||
|
&& atom.nucleus()->currentMode() == Inset::TEXT_MODE) {
|
||||||
|
MathAtom at = createInsetMath("text", buffer());
|
||||||
|
at.nucleus()->cell(0).push_back(atom);
|
||||||
|
niceInsert(at);
|
||||||
|
posForward();
|
||||||
|
} else
|
||||||
plainInsert(atom);
|
plainInsert(atom);
|
||||||
|
|
||||||
// finally put the macro argument behind, if needed
|
// finally put the macro argument behind, if needed
|
||||||
|
Loading…
Reference in New Issue
Block a user