From 40a3a44aa26c5b70dfcf9dad0fc388cbca975ffd Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 20 Dec 2017 16:00:39 +0100 Subject: [PATCH] tex2lyx: do not keep the Flex prefix for Flex insets names While there is code in LyX that handles this, tex2lyx should respect the format that LyX produces and the Flex: prefix is gone since cfeddb92 in 2014. In particular, this prefix is known to cause assertion when undoing a document setting change. --- src/tex2lyx/text.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 5330c624cf..f55053200b 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1994,7 +1994,11 @@ void parse_environment(Parser & p, ostream & os, bool outer, eat_whitespace(p, os, parent_context, false); parent_context.check_layout(os); begin_inset(os, "Flex "); - os << to_utf8(newinsetlayout->name()) << '\n' + docstring flex_name = newinsetlayout->name(); + // FIXME: what do we do if the prefix is not Flex: ? + if (prefixIs(flex_name, from_ascii("Flex:"))) + flex_name.erase(0, 5); + os << to_utf8(flex_name) << '\n' << "status collapsed\n"; if (newinsetlayout->isPassThru()) { string const arg = p.verbatimEnvironment(name); @@ -4803,7 +4807,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, p.get_token(); p.skip_spaces(); context.check_layout(os); - docstring const name = newinsetlayout->name(); + docstring name = newinsetlayout->name(); bool const caption = name.find(from_ascii("Caption:")) == 0; if (caption) { // Already done for floating minted listings. @@ -4812,6 +4816,9 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer, os << to_utf8(name.substr(8)) << '\n'; } } else { + // FIXME: what do we do if the prefix is not Flex: ? + if (prefixIs(name, from_ascii("Flex:"))) + name.erase(0, 5); begin_inset(os, "Flex "); os << to_utf8(name) << '\n' << "status collapsed\n";