Skip to content

Commit

Permalink
Send additional keyboard interrupt before quitting scene
Browse files Browse the repository at this point in the history
  • Loading branch information
Splines committed Oct 31, 2024
1 parent 2558008 commit 293b93d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/manimShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ export class ManimShell {
}
}
Logger.debug("🔆 User confirmed to kill active scene");
this.forceQuitActiveShell();
await this.forceQuitActiveShell();
}
this.activeShell = window.createTerminal();
} else {
Expand Down Expand Up @@ -391,9 +391,10 @@ export class ManimShell {
* running command (inside IPython) as would be expected.
* See https://github.com/3b1b/manim/discussions/2236
*/
public forceQuitActiveShell() {
public async forceQuitActiveShell() {
if (this.activeShell) {
Logger.debug("🔚 Force-quitting active shell");
await this.sendKeyboardInterrupt();
this.activeShell.dispose();
// This is also taken care of when we detect that the shell has ended
// in the `onDidEndTerminalShellExecution` event handler. However,
Expand Down Expand Up @@ -540,6 +541,7 @@ export class ManimShell {
private async sendKeyboardInterrupt() {
Logger.debug("💨 Sending keyboard interrupt to terminal");
await this.activeShell?.sendText('\x03'); // send `Ctrl+C`
await new Promise(resolve => setTimeout(resolve, 250));
}

/**
Expand All @@ -565,7 +567,7 @@ export class ManimShell {
// Manim detected in new terminal
if (this.activeShell && this.activeShell !== event.terminal) {
Logger.debug("👋 Manim detected in new terminal, exiting old scene");
this.forceQuitActiveShell();
await this.forceQuitActiveShell();
}
Logger.debug("👋 Manim welcome string detected");
this.activeShell = event.terminal;
Expand Down
2 changes: 1 addition & 1 deletion src/startStopScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ export async function startScene(lineStart?: number) {
* See `forceQuitActiveShell()` for more details.
*/
export async function exitScene() {
ManimShell.instance.forceQuitActiveShell();
await ManimShell.instance.forceQuitActiveShell();
}

0 comments on commit 293b93d

Please sign in to comment.