Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix preview command sometimes not executing on Windows #81

Merged
merged 4 commits into from
Nov 10, 2024

Conversation

RickLuiken
Copy link
Contributor

This PR attempts to fix the preview command on Windows. As seen in this video, sometimes checkpoint_paste() is not executed in the IPython shell, but it triggers the multiline input in IPython. In this PR, I detect the multiline input ("...:") and send "\x7F" to clear the extra line and send another newline to actually execute the command. This seems to fix the issue on my side. Let me know if you have any issues on other platforms!

Fixes #18

@Splines
Copy link
Member

Splines commented Nov 4, 2024

Nice, thanks! I will check if this still works for me. Generally, I'd favor a solution where we don't have to additionally detect the ...: string as that is of course one more thing where it could break in the future. So I assume the commands proposed in my comment here didn't work for you?

src/manimShell.ts Outdated Show resolved Hide resolved
@RickLuiken
Copy link
Contributor Author

I would also want to find a better solution than this. However, others have run into the same issue on the IPython repo and the vscode-python repo, so it does not seem to have an easy fix.

This solution should work out of the box for new users. Adding a delay between writing the command and the newline requires users to tweak the delay value.

Copy link
Member

@Splines Splines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good to me, just a few more minor comments.

src/manimShell.ts Outdated Show resolved Hide resolved
src/manimShell.ts Show resolved Hide resolved
src/manimShell.ts Show resolved Hide resolved
src/previewCode.ts Outdated Show resolved Hide resolved
@Splines
Copy link
Member

Splines commented Nov 4, 2024

This solution should work out of the box for new users. Adding a delay between writing the command and the newline requires users to tweak the delay value.

Yeah, this solution is definitely better than adding a delay. I just hope there will be a solution that gets to the root of this problem by means of a fix in the IPython repo or somewhere else where something like this would be tackled. But for now, if this fixes your problem that's already great and luckily this is also a fix that might be easily revertible once a solution is found in the future.

@RickLuiken
Copy link
Contributor Author

Sadly, I tried again with shell integration and this time it broke again... After some debugging I found that it thinks that there is a command running after sending the checkpoint_paste(). So, when sending the extra newline, it will first send a CTRL+C to stop the first command, deleting the checkpoint_paste() line. I haven't been able to break the sendText method, so let's stick to that for now.

@Splines
Copy link
Member

Splines commented Nov 5, 2024

Great, thanks for addressing all the points. The code looks good to me now. I just want to test this out a bit on my machine and ensure it doesn't break anything for me (we definitely need unit and integration tests in the very near future🙈, see #47). I will probably only be able to report on Friday as I'm a bit busy beforehand.

Copy link
Member

@Splines Splines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've tested it on my machine and it works fine. I've also checked that users can still enter the multi-line mode, e.g. when they manually type in a for-loop in the IPython shell. It works since you check for this.isExecutingCommand 👍

@Splines Splines merged commit 879a43b into Manim-Notebook:main Nov 10, 2024
Splines added a commit that referenced this pull request Jan 17, 2025
Splines added a commit that referenced this pull request Jan 19, 2025
Splines added a commit that referenced this pull request Jan 30, 2025
* Improve testing docstrings & add convenience methods

* Add laggy patched preview test & test sample

* Remove code of fix #81

* Increase grid size a bit

* Also try to remove ESC+ENTER

* Install patch in site-packages

* Remove patch from test samples

* Improve error handling for when patch fails

* Only apply fix on Windows

* Fix wrong filename in test

* Make scene laggier

* Also escape \r in python string

* Decrease grid size and increase timeout for tests

* Simplify retrieval of python binary in environment

* Add docstring for windows patch

* Add docstring to function that executes patch and waits for success

* Use success string that is not in source code itself

* Use `python` instead of `python3`

* Use Node.js `exec` instead of spawning new VSCode terminal

See this comment:
#117 (comment)

* Remove prints in Python patch

* Test that windows paste patch is correctly applied

* Fix logger import path

* Run all tests 🙈 (remove `it.only()` call)

* Restore accidentally deleted lines

* Assert that Logger.error() not called & use sinon.match

* Add a manual delay in test

* Stub Logger.info() and Logger.trace() to log outputs

* Don't stub/spy twice & only test windows patch

* Fix non-working windows paste patch test

* Rename function to `applyWindowsPastePatch`

* Increase timeout for windows paste patch test

* Try to use python3 instead of python

* Also inject Node.js exec() method for tests

* Remove Emoji in Python patch to avoid encoding issues

* Detect python in venv correctly on Windows & use `.exe`

* Also call `python.exe` instead of just `python` in tests

* Fix typo in windows paste patch

* Log output of `exec()` in pipeline

* Log separate groups of exec output

* Print patch command to console

* Get rid of \r in patch file for exec()

* Also escape backslashes

* Base64-encode/decode to get rid of nasty escape errors

* Get rid of console logs & run all tests

* Use color in Mocha TTY

* Do some final cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

executeCommand() doesn't execute the checkpoint_paste() command
3 participants