mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Fix bug #10581
Tell the math parser that we are parsing a macro definition, so that it doesn't try to return a verbatim copy in case of failure.
This commit is contained in:
parent
e36c661c61
commit
66aa52ff20
@ -71,7 +71,7 @@ bool MacroData::expand(vector<MathData> const & args, MathData & to) const
|
||||
InsetMathSqrt inset(const_cast<Buffer *>(buffer_));
|
||||
|
||||
docstring const & definition(display_.empty() ? definition_ : display_);
|
||||
asArray(definition, inset.cell(0), Parse::QUIET);
|
||||
asArray(definition, inset.cell(0), Parse::QUIET | Parse::MACRODEF);
|
||||
//lyxerr << "MathData::expand: args: " << args << endl;
|
||||
//LYXERR0("MathData::expand: ar: " << inset.cell(0));
|
||||
for (DocIterator it = doc_iterator_begin(buffer_, &inset); it; it.forwardChar()) {
|
||||
|
@ -672,7 +672,7 @@ void MathMacro::updateRepresentation(Cursor * cur, MacroContext const & mc,
|
||||
// get definition for list edit mode
|
||||
docstring const & display = d->macro_->display();
|
||||
asArray(display.empty() ? d->macro_->definition() : display,
|
||||
d->definition_, Parse::QUIET);
|
||||
d->definition_, Parse::QUIET | Parse::MACRODEF);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1757,7 +1757,8 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
|
||||
|
||||
else {
|
||||
success_ = false;
|
||||
if (!(mode_ & Parse::QUIET)) {
|
||||
if (!(mode_ & Parse::QUIET) &&
|
||||
!(mode_ & Parse::TRACKMACRO)) {
|
||||
dump();
|
||||
lyxerr << "found unknown math environment '"
|
||||
<< to_utf8(name) << "'" << endl;
|
||||
|
@ -28,7 +28,9 @@ enum flags {
|
||||
/// Wrap unicode symbols in \text{}.
|
||||
USETEXT = 0x08,
|
||||
/// Track macro creation while loading a document
|
||||
TRACKMACRO = 0x10
|
||||
TRACKMACRO = 0x10,
|
||||
/// Parse a macro definition
|
||||
MACRODEF = 0x20
|
||||
};
|
||||
|
||||
|
||||
|
@ -961,8 +961,13 @@ docstring asString(MathData const & ar)
|
||||
|
||||
void asArray(docstring const & str, MathData & ar, Parse::flags pf)
|
||||
{
|
||||
// If the QUIET flag is set, we are going to parse for either
|
||||
// a paste operation or a macro definition. We try to do the
|
||||
// right thing in all cases.
|
||||
|
||||
bool quiet = pf & Parse::QUIET;
|
||||
if ((str.size() == 1 && quiet) || (!mathed_parse_cell(ar, str, pf) && quiet))
|
||||
bool macro = pf & Parse::MACRODEF;
|
||||
if ((str.size() == 1 && quiet) || (!mathed_parse_cell(ar, str, pf) && quiet && !macro))
|
||||
mathed_parse_cell(ar, str, pf | Parse::VERBATIM);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user