On Mon, Jun 16, 2008 at 02:32:52PM -0000, [EMAIL PROTECTED] wrote: > Author: forenr > Date: Mon Jun 16 16:32:51 2008 > New Revision: 25273 > > URL: http://www.lyx.org/trac/changeset/25273 > Log: > Use a helper method in order to avoid code repetition.
> URL: > http://www.lyx.org/trac/file/lyx-devel/trunk/src/mathed/InsetMathSqrt.cpp?rev=25273 > ============================================================================== > --- lyx-devel/trunk/src/mathed/InsetMathSqrt.cpp (original) > +++ lyx-devel/trunk/src/mathed/InsetMathSqrt.cpp Mon Jun 16 16:32:51 2008 > @@ -80,13 +80,7 @@ > > void InsetMathSqrt::write(WriteStream & os) const > { > - bool brace = os.pendingBrace(); > - os.pendingBrace(false); > - if (os.latex() && os.textMode()) { > - os << "\\ensuremath{"; > - os.textMode(false); > - brace = true; > - } > + bool brace = ensureMath(os); > os << "\\sqrt{" << cell(0) << '}'; > os.pendingBrace(brace); > } Although this is better than the duplication I'd have prefered something along the lines of class MathEnsurer { public: explicit MathEnsurer(WriteStream & os) : os_(os), brace_(ensureMath(os)) {} ~MathEnsurer() { os_.pendingBrace(brace_); private: WriteStream & os_; bool brace_; }; void InsetMathSqrt::write(WriteStream & os) const { MathEnsurer ensurer(os); os << "\\sqrt{" << cell(0) << '}'; } Possibly this code does not even have to be in the individual insets but could be handled generically in InsetMathNest or such. Also, as a general remark, I'd like patches touching 26 math insets to be at least annouced to the list before committing... Andre'