+ // If this is the last par of an inset, the language needs
+ // to be closed after the environment
+ if (lastpar && !maintext) {
+ if (using_begin_end && langOpenedAtThisLevel(state)) {
+ if (isLocalSwitch(state)) {
+ os << "}";
+ } else {
+ os << "\\end{"
+ << openLanguageName(state)
+ << "}%\n";
+ }
+ popLanguageName();
+ }
+ }