- changed status to resolved
Better extraction of lines from JSON (handle newline literals, hard-wrapping)
Currently, the frontend splits the source-code into lines wherever the substring \n
appears in the JSON. This means newline literals between single- or double-quotes are parsed as indicating a new line of code, so that a simple expression such as:
std::cout << "\n\n\n";
is treated as multiple lines, with only the ;
"line" being coloured as if it was executed. In addition to being a display issue, this results in any subsequent lines of code to have incorrect execution counts displayed, not, since there end up being more lines of source code than execution/debugger steps. See e.g. the third example output produced from running cargo run
(json/simple.json).
Likewise, (although I will need to actually test this some actual output from the backend), hard-wrapped lines will (almost certainly) cause similar mismatching and display problems.
The first problem should be solvable (entirely on the front-end) with a simple reg-ex.
The second will probably require a little more thought, but using some simple heuristics that rely on common code styles [e.g. checking for ;\n
, }\n
, or \n.
(i.e. multi-line chained method calls)] would probably still go a long way for the vast majority of cases, without requiring any actual / proper parsing of the source code.
Comments (1)
-
reporter - Log in to comment
This doesn't actually seem to be an issue as of now, one of the apparent reasons for a problem with newlines seems to have been a typo in one of the earlier (manually created) json outputs.
I am closing this issue, and a new issue can be opened if this turns out to be an issue for some backend output later.