diff --git a/src/mathed/MacroTable.h b/src/mathed/MacroTable.h index 3bd04ea917..030e6f74ca 100644 --- a/src/mathed/MacroTable.h +++ b/src/mathed/MacroTable.h @@ -69,6 +69,8 @@ public: char const * MathMLtype() const; /// void setSymbol(latexkeys const * sym) { sym_ = sym; } + /// + DocIterator const & pos() { return pos_; } /// lock while being drawn to avoid recursions int lock() const { return ++lockCount_; } diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index 24ebe77645..8f2d15fefc 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -203,6 +203,14 @@ MathMacro::MathMacro(MathMacro const & that) : InsetMathNest(that), d(new Private(*that.d)) { d->updateChildren(this); + if (d->macro_ && lyxrc.preview == LyXRC::PREVIEW_ON) { + // We need to update d->macro_ by ourselves because in this case + // MathData::metrics() is not called when selecting a math inset + DocIterator const & pos = d->macroBackup_.pos(); + d->macro_ = pos.buffer()->getMacro(name(), pos); + if (!d->macro_) + d->macro_ = &d->macroBackup_; + } } @@ -213,6 +221,14 @@ MathMacro & MathMacro::operator=(MathMacro const & that) InsetMathNest::operator=(that); *d = *that.d; d->updateChildren(this); + if (d->macro_ && lyxrc.preview == LyXRC::PREVIEW_ON) { + // We need to update d->macro_ by ourselves because in this case + // MathData::metrics() is not called when selecting a math inset + DocIterator const & pos = d->macroBackup_.pos(); + d->macro_ = pos.buffer()->getMacro(name(), pos); + if (!d->macro_) + d->macro_ = &d->macroBackup_; + } return *this; }