Skip to content
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;

/**
* 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`);
// \x7F deletes the extra line ("...:") from IPython
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`;
const PREVIEW_COMMAND = `\x0Ccheckpoint_paste()`;
// \x0C: is Ctrl + L
// \x1b: https://github.com/bhoov/manim-notebook/issues/18#issuecomment-2431146809

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