reeborg
reeborg copied to clipboard
Subtract nb of code lines in Pre to get proper line number information for error messages
When pre code is present, it is concatenated with user code before being run. As a result, the line number shown for errors does not correspond to user code. This should be fixed, but likely only after upgrading to CodeMirror v6.
See also #463
Instead of subtracting the line number, it might be more fool-proof to run separately the post code first, then the user code followed by the post-code.
Also, check to see if blank lines at the beginning of Python code are not messing up the line number provided by Brython. It that is the case, perhaps something like
if src.startswith('\n'):
src = "#" + src
prior to executing the code might do the trick.
See also #474.