I've attached a patch that fix the return value of InsetFormula::latex. The fix is done by counting the number of \n chars in every string that is written to WriteStream.
A more efficient solution is to check for \n only in WriteStream::operator<<(char c), but this will make the code ugly, because we will then need to use os << "\begin{equation}" << '\n' instead of os << "\begin{equation}\n"
patch.gz
Description: GNU Zip compressed data