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
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/manimShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const ANSI_CONTROL_SEQUENCE_REGEX = /(?:\x1B[@-Z\\-_]|[\x80-\x9A\x9C-\x9F]|(?:\x
*/
const IPYTHON_CELL_START_REGEX = /^\s*In \[\d+\]:/gm;

/**
* Regular expression to match IPython multiline input "...:"
*/
const IPYTHON_MULTILINE_START_REGEX = /^\s*\.{3}:\s+$/m;

Splines marked this conversation as resolved.
Show resolved Hide resolved
/**
* Regular expression to match a KeyboardInterrupt.
*/
Expand Down Expand Up @@ -657,6 +662,12 @@ export class ManimShell {
this.eventEmitter.emit(ManimShellEvent.IPYTHON_CELL_FINISHED);
}

if (this.isExecutingCommand && data.match(IPYTHON_MULTILINE_START_REGEX)) {
Logger.debug(`💨 IPython multiline detected, sending extra newline`);
RickLuiken marked this conversation as resolved.
Show resolved Hide resolved
// \x7F deletes the extra line ("...:") from IPython
Splines marked this conversation as resolved.
Show resolved Hide resolved
this.exec(this.activeShell, "\x7F");
}

if (data.match(ERROR_REGEX)) {
Logger.debug("🚨 Error in IPython cell detected");
this.activeShell?.show();
Expand Down
3 changes: 1 addition & 2 deletions src/previewCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import { ManimShell } from './manimShell';
import { EventEmitter } from 'events';
import { Logger } from './logger';

const PREVIEW_COMMAND = `\x0C checkpoint_paste()\x1b`;
VladimirFokow marked this conversation as resolved.
Show resolved Hide resolved
const PREVIEW_COMMAND = `\x0Ccheckpoint_paste()`;
// \x0C: is Ctrl + L
RickLuiken marked this conversation as resolved.
Show resolved Hide resolved
// \x1b: https://github.com/bhoov/manim-notebook/issues/18#issuecomment-2431146809

/**
* Interactively previews the given Manim code by means of the
Expand Down