Good job! However, I may have found a bug related to cell code mode.
Consider this piece of code
s1 = 'hello\n';
s2 = 'h\n';
if you run it as a normal script (using F5) everything is fine. But if you run the same code in cell mode (using CTRL+Enter) the result is not what you expected.
This is driving me crazy. I use Matlab R2013b and I use lots of cell code in my scripts, so this is giving me some annoyance.
This is even more complicated since if you try to run the code in debug mode, the problem doesn't show up anymore!
I think the problem is related to the fact that, when using cell code mode, the name of the script file is not passed to the command window (while it appears in the cmd window when using F5) and this in some way reflects in the computation of the current position in the command window.