mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +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/InsetMathBrace.h"
|
||||
#include "mathed/InsetMathEnsureMath.h"
|
||||
#include "mathed/InsetMathScript.h"
|
||||
#include "mathed/MacroTable.h"
|
||||
#include "mathed/MathData.h"
|
||||
#include "mathed/MathFactory.h"
|
||||
#include "mathed/MathMacro.h"
|
||||
|
||||
#include <sstream>
|
||||
@ -1447,7 +1449,20 @@ bool Cursor::macroModeClose()
|
||||
else if (atom.nucleus()->nargs() > 0)
|
||||
atom.nucleus()->cell(0).append(selection);
|
||||
|
||||
plainInsert(atom);
|
||||
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);
|
||||
|
||||
// finally put the macro argument behind, if needed
|
||||
if (macroArg) {
|
||||
|
Loading…
Reference in New Issue
Block a user