diff --git a/src/extension.ts b/src/extension.ts index daab10dc..fb883c8a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -171,11 +171,11 @@ async function clearScene() { await ManimShell.instance.executeCommandErrorOnNoActiveSession("clear()"); } catch (error) { if (error instanceof NoActiveShellError) { - Window.showErrorMessage('No active Manim session found to remove objects from.'); - } else { - Logger.error(`💥 Error while trying to remove objects from scene: ${error}`); - throw error; + Window.showWarningMessage('No active Manim session found to remove objects from.'); + return; } + Logger.error(`💥 Error while trying to remove objects from scene: ${error}`); + throw error; } } diff --git a/src/manimShell.ts b/src/manimShell.ts index 61fbb7d0..a29daee8 100644 --- a/src/manimShell.ts +++ b/src/manimShell.ts @@ -259,8 +259,8 @@ export class ManimShell { return; } - if (errorOnNoActiveShell && !this.hasActiveShell()) { - throw new NoActiveShellError(); + if (errorOnNoActiveShell) { + this.errorOnNoActiveShell(); } if (this.isExecutingCommand) { @@ -312,6 +312,15 @@ export class ManimShell { } } + /** + * Errors if no active shell is found. + */ + public errorOnNoActiveShell() { + if (!this.hasActiveShell()) { + throw new NoActiveShellError(); + } + } + /** * This command should only be used from within the actual `startScene()` * method. It starts a new ManimGL scene in the terminal and waits until diff --git a/src/startStopScene.ts b/src/startStopScene.ts index 02e76bc7..c2e6a1fd 100644 --- a/src/startStopScene.ts +++ b/src/startStopScene.ts @@ -111,5 +111,15 @@ export async function startScene(lineStart?: number) { * See `forceQuitActiveShell()` for more details. */ export async function exitScene() { - await ManimShell.instance.forceQuitActiveShell(); + try { + ManimShell.instance.errorOnNoActiveShell(); + await ManimShell.instance.forceQuitActiveShell(); + } catch (error) { + if (error instanceof NoActiveShellError) { + Window.showWarningMessage("No active Manim session found to quit."); + return; + } + Logger.error(`💥 Error while trying to exit the scene: ${error}`); + throw error; + } }