# Bug? Colored frame in mcode package

While using mcode.sty, I recognized that at linebreaks with long comments parts of the surrounding frame got colored green or were even left white at using mathematical formulas, e.g. in the following example:

\documentclass{article}

% load package with framed'' and numbered'' option.
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

% something NOT relevant to the usage of the package.
\setlength{\parindent}{0pt}
\setlength{\parskip}{18pt}

\begin{document}
\begin{itemize}
\item The following demo block shows the problems:
\begin{lstlisting}
for i = 1:3
if i >= 5                    % literate programming replacement
disp('cool');           % comment with some §\mcommentfont\LaTeX in it: $\mcommentfont\pi x^2$§
end
really really long really really long really really long really really long really really long line % blaaaaaaaa
end
\end{lstlisting}
\end{itemize}
\end{document}


How can uniformly black colored frames be achieved?

-
I have removed my previous comment, I misinterpreted your question. –  Dennis Jaheruddin Feb 13 '13 at 13:33
You forgot to include a list-environment (e.g. itemize) in your code. The problem only seems to occur in a list, if you remove the \item from your code everything works fine. –  Torbjørn T. Feb 13 '13 at 19:53
@TorbjørnT.: Thank you for your comment - that environment enabled me to see the bug (because of the smaller textwidth)! –  strpeter Feb 15 '13 at 8:12
I hope now people can see the remaining problem/conflict of the frame with math code inside the lstlisting-environment. –  strpeter Feb 15 '13 at 8:17
For information, this isn't a problem specific to the mcode package, but also occurs with the listings package (which mcode is built on). –  Jubobs Feb 27 at 11:09

The first problem can be solved (I think it is a bug in the package mcode.sty) quite simply by adding a few lines of code just after including \usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}:
\lstset{