Fix IPython cell detection (multiple ones in one datastream) #64
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #52. At least I hope I've fixed the problem identified by @VladimirFokow in the first log. Please tell me if this PR also fixes the other problems of that issue. If not, I will take a look at them as well.
The issue could be identified by comparing logs on different machines. Here only the most relevant parts:
On Linux (WSL)
On MacOS
See the difference? On Linux I get two separate data streams and each one only contains one IPython Cell identifier. This is not the case for MacOS. Therefore, I changed the RegEx to globally match multiple occurrences in a data stream and then just take the maximum number I have found, in this example: 2.
Note the fixed approach is coherent with
https://github.com/bhoov/manim-notebook/blob/b4ec9bbe242a3d120d2674091c046f1962f29809/src/manimShell.ts#L478
since this will evaluate to true if the seen cell count is higher than the current cell count. So even if we skip over cells via this new tactic, we will definitely end the old ones when a cell higher than the current execution count is seen.