continue;
// get macro data
- InsetMathMacroTemplate & macroTemplate =
- *insit.inset->asInsetMath()->asMacroTemplate();
- MacroContext mc(&buffer(), it);
- macroTemplate.updateToContext(mc);
-
- // valid?
- bool valid = macroTemplate.validMacro();
- // FIXME: Should be fixNameAndCheckIfValid() in fact,
- // then the BufferView's cursor will be invalid in
- // some cases which leads to crashes.
- if (!valid)
- continue;
-
- // register macro
- buffer().registerMacro(macroTemplate.name(), it, ourscope);
+ InsetMathMacroTemplate * macroTemplate =
+ insit.inset->asInsetMath()->asMacroTemplate();
+ macroTemplate->updateMacros(it, ourscope);
}
// next paragraph
}
+void InsetMathMacroTemplate::updateMacros(DocIterator const & us, DocIterator const & scope)
+{
+ // This matches the previous code, but I am not sure why it
+ // should be like this.
+ DocIterator it = us;
+ it.pop_back();
+ MacroContext mc(&buffer(), it);
+ updateToContext(mc);
+ // FIXME: Should be fixNameAndCheckIfValid() in fact,
+ // then the BufferView's cursor will be invalid in
+ // some cases which leads to crashes.
+ if (!validMacro())
+ return;
+
+ // register macro
+ buffer().registerMacro(name(), it, scope);
+}
+
+
void InsetMathMacroTemplate::updateToContext(MacroContext const & mc)
{
redefinition_ = mc.get(name()) != nullptr;
/// decide whether its a redefinition
void updateToContext(MacroContext const & mc);
+ ///
+ void updateMacros(DocIterator const & us, DocIterator const & scope) override;
///
void draw(PainterInfo & pi, int x, int y) const override;