From 2e48202bb0802a6cf0064f7137b51da565d7d52a Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 29 Oct 2024 11:53:35 +0100 Subject: [PATCH 1/9] Add logging to notification messages --- src/extension.ts | 21 ++++++++++----------- src/logger.ts | 24 +++++++++++++++++++++++- src/manimCell.ts | 4 ++-- src/manimShell.ts | 16 ++++++++++------ src/previewCode.ts | 4 ++-- src/startStopScene.ts | 11 ++++++----- 6 files changed, 53 insertions(+), 27 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index ed40993c..cc507b8e 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -5,8 +5,7 @@ import { ManimCell } from './manimCell'; import { ManimCellRanges } from './manimCellRanges'; import { previewCode } from './previewCode'; import { startScene, exitScene } from './startStopScene'; -import { loggerName } from './logger'; -import Logger from './logger'; +import { Logger, Window, loggerName } from './logger'; export function activate(context: vscode.ExtensionContext) { @@ -74,7 +73,7 @@ async function previewManimCell(cellCode?: string, startLine?: number) { if (cellCode === undefined) { const editor = window.activeTextEditor; if (!editor) { - window.showErrorMessage( + Window.showErrorMessage( 'No opened file found. Place your cursor in a Manim cell.'); return; } @@ -84,7 +83,7 @@ async function previewManimCell(cellCode?: string, startLine?: number) { const cursorLine = editor.selection.active.line; const range = ManimCellRanges.getCellRangeAtLine(document, cursorLine); if (!range) { - window.showErrorMessage('Place your cursor in a Manim cell.'); + Window.showErrorMessage('Place your cursor in a Manim cell.'); return; } cellCode = document.getText(range); @@ -92,7 +91,7 @@ async function previewManimCell(cellCode?: string, startLine?: number) { } if (startLineFinal === undefined) { - window.showErrorMessage('Internal error: Line number not found in `previewManimCell()`.'); + Window.showErrorMessage('Internal error: Line number not found in `previewManimCell()`.'); return; } @@ -105,7 +104,7 @@ async function previewManimCell(cellCode?: string, startLine?: number) { async function previewSelection() { const editor = window.activeTextEditor; if (!editor) { - window.showErrorMessage('Select some code to preview.'); + Window.showErrorMessage('Select some code to preview.'); return; } @@ -125,7 +124,7 @@ async function previewSelection() { } if (!selectedText) { - window.showErrorMessage('Select some code to preview.'); + Window.showErrorMessage('Select some code to preview.'); return; } @@ -140,7 +139,7 @@ async function clearScene() { try { await ManimShell.instance.executeCommandErrorOnNoActiveSession("clear()"); } catch (NoActiveSessionError) { - window.showErrorMessage('No active Manim session found to remove objects from.'); + Window.showErrorMessage('No active Manim session found to remove objects from.'); } } @@ -185,7 +184,7 @@ function registerManimCellProviders(context: vscode.ExtensionContext) { */ function openLogFile(context: vscode.ExtensionContext) { const logFilePath = vscode.Uri.joinPath(context.logUri, `${loggerName}.log`); - vscode.window.withProgress({ + window.withProgress({ location: vscode.ProgressLocation.Notification, title: "Opening Manim Notebook log file...", cancellable: false @@ -193,9 +192,9 @@ function openLogFile(context: vscode.ExtensionContext) { await new Promise(async (resolve) => { try { const doc = await vscode.workspace.openTextDocument(logFilePath); - await vscode.window.showTextDocument(doc); + await window.showTextDocument(doc); } catch { - vscode.window.showErrorMessage("Could not open Manim Notebook log file"); + Window.showErrorMessage("Could not open Manim Notebook log file"); } finally { resolve(); } diff --git a/src/logger.ts b/src/logger.ts index 3c4fe72f..e4931587 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -4,7 +4,7 @@ import * as path from 'path'; export const loggerName = 'Manim Notebook'; const logger = window.createOutputChannel(loggerName, { log: true }); -export default class Logger { +export class Logger { public static trace(message: string) { logger.trace(`${Logger.getFormattedCallerInformation()} ${message}`); @@ -87,3 +87,25 @@ export default class Logger { return `[${fileName}] [${methodName}]`; } } + +/** + * Class that wraps some VSCode window methods to log the messages before + * displaying them to the user as a notification. + */ +export class Window { + + public static showInformationMessage(message: string) { + Logger.info(message); + window.showInformationMessage(message); + } + + public static showWarningMessage(message: string, ...items: string[]) { + Logger.warn(message); + window.showWarningMessage(message, ...items); + } + + public static showErrorMessage(message: string) { + Logger.error(message); + window.showErrorMessage(message); + } +} diff --git a/src/manimCell.ts b/src/manimCell.ts index a24174e0..1949e192 100644 --- a/src/manimCell.ts +++ b/src/manimCell.ts @@ -38,11 +38,11 @@ export class ManimCell implements vscode.CodeLensProvider, vscode.FoldingRangePr } public resolveCodeLens(codeLens: vscode.CodeLens, token: vscode.CancellationToken): vscode.CodeLens { - if (!vscode.window.activeTextEditor) { + if (!window.activeTextEditor) { return codeLens; } - const document = vscode.window.activeTextEditor?.document; + const document = window.activeTextEditor?.document; const range = new vscode.Range(codeLens.range.start, codeLens.range.end); const cellCode = document.getText(range); diff --git a/src/manimShell.ts b/src/manimShell.ts index db35f886..eea35ada 100644 --- a/src/manimShell.ts +++ b/src/manimShell.ts @@ -3,6 +3,7 @@ import { window } from 'vscode'; import { Terminal } from 'vscode'; import { startScene, exitScene } from './startStopScene'; import { EventEmitter } from 'events'; +import { Logger, Window } from './logger'; /** * Regular expression to match ANSI control sequences. Even though we might miss @@ -230,12 +231,12 @@ export class ManimShell { ) { if (!errorOnNoActiveShell && startLine === undefined) { // should never happen if method is called correctly - window.showErrorMessage("Start line not set. Internal extension error."); + Window.showErrorMessage("Start line not set. Internal extension error."); return; } if (this.lockDuringStartup) { - window.showWarningMessage("Manim is currently starting. Please wait a moment."); + Window.showWarningMessage("Manim is currently starting. Please wait a moment."); return; } @@ -246,7 +247,7 @@ export class ManimShell { if (this.isExecutingCommand) { // MacOS specific behavior if (this.shouldLockDuringCommandExecution && !forceExecute) { - window.showWarningMessage( + Window.showWarningMessage( `Simultaneous Manim commands are not currently supported on MacOS. ` + `Please wait for the current operations to finish before initiating ` + `a new command.`); @@ -342,6 +343,7 @@ export class ManimShell { * command execution. */ public resetActiveShell() { + Logger.debug("Reset active shell"); this.iPythonCellCount = 0; this.activeShell = null; this.shellWeTryToSpawnIn = null; @@ -358,7 +360,7 @@ export class ManimShell { const CANCEL_OPTION = "Cancel"; const KILL_IT_ALWAYS_OPTION = "Kill it (don't ask the next time)"; - const selection = await window.showWarningMessage( + const selection = await Window.showWarningMessage( "We need to kill your Manim session to spawn a new one.", "Kill it", KILL_IT_ALWAYS_OPTION, CANCEL_OPTION); if (selection === undefined || selection === CANCEL_OPTION) { @@ -368,7 +370,7 @@ export class ManimShell { if (selection === KILL_IT_ALWAYS_OPTION) { await vscode.workspace.getConfiguration("manim-notebook") .update("confirmKillingActiveSceneToStartNewOne", false); - window.showInformationMessage( + Window.showInformationMessage( "You can re-enable the confirmation in the settings."); } return true; @@ -404,8 +406,10 @@ export class ManimShell { private exec(shell: Terminal, command: string) { this.detectShellExecutionEnd = false; if (shell.shellIntegration) { + Logger.debug(`Sending command to terminal (with shell integration): ${command}`); shell.shellIntegration.executeCommand(command); } else { + Logger.debug(`Sending command to terminal (without shell integration): ${command}`); shell.sendText(command); } this.detectShellExecutionEnd = true; @@ -511,7 +515,7 @@ export class ManimShell { if (this.shellWeTryToSpawnIn === event.terminal) { this.eventEmitter.emit(ManimShellEvent.MANIM_NOT_STARTED); this.resetActiveShell(); - window.showErrorMessage( + Window.showErrorMessage( "Manim session could not be started." + " Have you verified that `manimgl` is installed?"); event.terminal.show(); diff --git a/src/previewCode.ts b/src/previewCode.ts index 1b244679..aa1fcb67 100644 --- a/src/previewCode.ts +++ b/src/previewCode.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; -import { ManimShell } from './manimShell'; import { window } from 'vscode'; +import { ManimShell } from './manimShell'; import { EventEmitter } from 'events'; const PREVIEW_COMMAND = `\x0C checkpoint_paste()\x1b`; @@ -77,7 +77,7 @@ class PreviewProgress { private animationName: string | undefined; constructor() { - vscode.window.withProgress({ + window.withProgress({ location: vscode.ProgressLocation.Notification, title: "Previewing Manim", cancellable: false diff --git a/src/startStopScene.ts b/src/startStopScene.ts index 12d0326b..9cfbf5c3 100644 --- a/src/startStopScene.ts +++ b/src/startStopScene.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode'; import { ManimShell } from './manimShell'; import { window } from 'vscode'; +import { Logger, Window } from './logger'; /** * Runs the `manimgl` command in the terminal, with the current cursor's line number: @@ -24,7 +25,7 @@ import { window } from 'vscode'; export async function startScene(lineStart?: number) { const editor = window.activeTextEditor; if (!editor) { - window.showErrorMessage( + Window.showErrorMessage( 'No opened file found. Please place your cursor at a line of code.' ); return; @@ -35,7 +36,7 @@ export async function startScene(lineStart?: number) { const languageId = editor.document.languageId; if (languageId !== 'python') { - window.showErrorMessage("You don't have a Python file open."); + Window.showErrorMessage("You don't have a Python file open."); return; } @@ -55,7 +56,7 @@ export async function startScene(lineStart?: number) { .reverse() .find(({ index }) => index <= cursorLine); if (!matchingClass) { - window.showErrorMessage('Place your cursor in Manim code inside a class.'); + Window.showErrorMessage('Place your cursor in Manim code inside a class.'); return; } // E.g. here, sceneName = "SelectedScene" @@ -110,7 +111,7 @@ export async function startScene(lineStart?: number) { export async function exitScene() { try { await ManimShell.instance.executeCommandErrorOnNoActiveSession("exit()", false, true); - } catch(NoActiveSessionError) { - window.showErrorMessage('No active Manim session found to exit.'); + } catch (NoActiveSessionError) { + Window.showErrorMessage('No active Manim session found to exit.'); } } From 0e62232098d8e53914f7c5597ee60da8e6ff128d Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 29 Oct 2024 11:59:00 +0100 Subject: [PATCH 2/9] Add icons to Window logger --- src/logger.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/logger.ts b/src/logger.ts index e4931587..24f77780 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -95,17 +95,17 @@ export class Logger { export class Window { public static showInformationMessage(message: string) { - Logger.info(message); + Logger.info(`๐Ÿ’ก ${message}`); window.showInformationMessage(message); } public static showWarningMessage(message: string, ...items: string[]) { - Logger.warn(message); + Logger.warn(`๐Ÿ’ก ${message}`); window.showWarningMessage(message, ...items); } public static showErrorMessage(message: string) { - Logger.error(message); + Logger.error(`๐Ÿ’ก ${message}`); window.showErrorMessage(message); } } From 380d3b0078b5d3b276960be9aff9fb3d97997d3c Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 29 Oct 2024 12:11:43 +0100 Subject: [PATCH 3/9] Add Logger statements all over the place --- src/extension.ts | 12 ++++++++++-- src/manimShell.ts | 31 +++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index cc507b8e..4c0f486b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -14,35 +14,41 @@ export function activate(context: vscode.ExtensionContext) { const previewManimCellCommand = vscode.commands.registerCommand( 'manim-notebook.previewManimCell', (cellCode?: string, startLine?: number) => { + Logger.info(`๐Ÿ’  Command requested: Preview Manim Cell, startLine=${startLine}`); previewManimCell(cellCode, startLine); }); const previewSelectionCommand = vscode.commands.registerCommand( 'manim-notebook.previewSelection', () => { + Logger.info("๐Ÿ’  Command requested: Preview Selection"); previewSelection(); } ); const startSceneCommand = vscode.commands.registerCommand( 'manim-notebook.startScene', () => { + Logger.info("๐Ÿ’  Command requested: Start Scene"); startScene(); } ); const exitSceneCommand = vscode.commands.registerCommand( 'manim-notebook.exitScene', () => { + Logger.info("๐Ÿ’  Command requested: Exit Scene"); exitScene(); } ); const clearSceneCommand = vscode.commands.registerCommand( 'manim-notebook.clearScene', () => { + Logger.info("๐Ÿ’  Command requested: Clear Scene"); clearScene(); } ); const openLogFileCommand = vscode.commands.registerCommand( 'manim-notebook.openLogFile', async () => { + Logger.info("๐Ÿ’  Command requested: Open Log File"); openLogFile(context); }); @@ -59,7 +65,9 @@ export function activate(context: vscode.ExtensionContext) { Logger.info("Manim Notebook activated"); } -export function deactivate() { } +export function deactivate() { + Logger.info("๐Ÿ’  Manim Notebook extension deactivated"); +} /** * Previews the Manim code of the cell where the cursor is placed @@ -206,4 +214,4 @@ function openLogFile(context: vscode.ExtensionContext) { // https://github.com/microsoft/vscode/blob/9de080f7cbcec77de4ef3e0d27fbf9fd335d3fba/extensions/typescript-language-features/src/typescriptServiceClient.ts#L580-L586 }); }); -} \ No newline at end of file +} diff --git a/src/manimShell.ts b/src/manimShell.ts index eea35ada..f93cf557 100644 --- a/src/manimShell.ts +++ b/src/manimShell.ts @@ -229,6 +229,9 @@ export class ManimShell { startLine?: number, handler?: CommandExecutionEventHandler ) { + Logger.debug(`๐Ÿš€ Exec command: ${command}, waitUntilFinished=${waitUntilFinished}` + + `, forceExecute=${forceExecute}, errorOnNoActiveShell=${errorOnNoActiveShell}`); + if (!errorOnNoActiveShell && startLine === undefined) { // should never happen if method is called correctly Window.showErrorMessage("Start line not set. Internal extension error."); @@ -259,6 +262,7 @@ export class ManimShell { } this.isExecutingCommand = true; + Logger.debug("๐Ÿ”’ Command execution locked"); let shell: Terminal; if (errorOnNoActiveShell) { @@ -278,11 +282,14 @@ export class ManimShell { handler?.onCommandIssued?.(); this.waitUntilCommandFinished(currentExecutionCount, () => { + Logger.debug("๐Ÿ”“ Command execution unlocked"); this.isExecutingCommand = false; this.eventEmitter.off(ManimShellEvent.DATA, dataListener); }); if (waitUntilFinished) { + Logger.debug(`๐Ÿ•’ Waiting until command has finished: ${command}`); await this.waitUntilCommandFinished(currentExecutionCount); + Logger.debug(`๐Ÿ•’ Command has finished: ${command}`); } } @@ -305,6 +312,7 @@ export class ManimShell { */ public async executeStartCommand(command: string, isRequestedForAnotherCommand: boolean) { if (!isRequestedForAnotherCommand) { + Logger.debug("๐Ÿ”† Executing start command that is requested for its own"); if (this.hasActiveShell()) { const shouldAsk = await vscode.workspace.getConfiguration("manim-notebook") .get("confirmKillingActiveSceneToStartNewOne"); @@ -316,6 +324,8 @@ export class ManimShell { exitScene(); } this.activeShell = window.createTerminal(); + } else { + Logger.debug("๐Ÿ”† Executing start command that is requested for another command"); } await window.withProgress({ @@ -336,6 +346,8 @@ export class ManimShell { this.shellWeTryToSpawnIn = null; }); + + Logger.debug("๐Ÿ”† Execute Start command finished"); } /** @@ -406,10 +418,10 @@ export class ManimShell { private exec(shell: Terminal, command: string) { this.detectShellExecutionEnd = false; if (shell.shellIntegration) { - Logger.debug(`Sending command to terminal (with shell integration): ${command}`); + Logger.debug(`๐Ÿ’จ Sending command to terminal (with shell integration): ${command}`); shell.shellIntegration.executeCommand(command); } else { - Logger.debug(`Sending command to terminal (without shell integration): ${command}`); + Logger.debug(`๐Ÿ’จ Sending command to terminal (without shell integration): ${command}`); shell.sendText(command); } this.detectShellExecutionEnd = true; @@ -426,8 +438,12 @@ export class ManimShell { */ private async retrieveOrInitActiveShell(startLine: number): Promise { if (!this.hasActiveShell()) { + Logger.debug("๐Ÿ” No active shell found, requesting startScene"); this.activeShell = window.createTerminal(); await startScene(startLine); + Logger.debug("๐Ÿ” Started new scene to retrieve new shell"); + } else { + Logger.debug("๐Ÿ” Active shell already there"); } return this.activeShell as Terminal; } @@ -464,6 +480,7 @@ export class ManimShell { } private async sendKeyboardInterrupt() { + Logger.debug("๐Ÿ’จ Sending keyboard interrupt to terminal"); this.activeShell?.sendText('\x03'); // send `Ctrl+C` } @@ -484,16 +501,21 @@ export class ManimShell { async (event: vscode.TerminalShellExecutionStartEvent) => { const stream = event.execution.read(); for await (const data of withoutAnsiCodes(stream)) { + Logger.trace(`๐Ÿงพ: ${data}`); + this.eventEmitter.emit(ManimShellEvent.DATA, data); if (data.match(MANIM_WELCOME_REGEX)) { if (this.activeShell && this.activeShell !== event.terminal) { + Logger.debug("Manim detected in new terminal, exiting old scene"); exitScene(); // Manim detected in new terminal } + Logger.debug("๐Ÿ‘‹ Manim welcome string detected"); this.activeShell = event.terminal; } if (data.match(KEYBOARD_INTERRUPT_REGEX)) { + Logger.debug("๐Ÿ›‘ Keyboard interrupt detected"); this.eventEmitter.emit(ManimShellEvent.KEYBOARD_INTERRUPT); } @@ -501,10 +523,12 @@ export class ManimShell { if (ipythonMatch) { const cellNumber = parseInt(ipythonMatch[0].match(/\d+/)![0]); this.iPythonCellCount = cellNumber; + Logger.debug(`๐Ÿ“ฆ IPython cell ${cellNumber} detected`); this.eventEmitter.emit(ManimShellEvent.IPYTHON_CELL_FINISHED); } if (data.match(ERROR_REGEX)) { + Logger.debug("๐Ÿšจ Error in IPython cell detected"); this.activeShell?.show(); } } @@ -513,6 +537,7 @@ export class ManimShell { window.onDidEndTerminalShellExecution( async (event: vscode.TerminalShellExecutionEndEvent) => { if (this.shellWeTryToSpawnIn === event.terminal) { + Logger.debug("โŒ Tried to spawn a new Manim session, but it failed"); this.eventEmitter.emit(ManimShellEvent.MANIM_NOT_STARTED); this.resetActiveShell(); Window.showErrorMessage( @@ -523,10 +548,12 @@ export class ManimShell { } if (!this.detectShellExecutionEnd) { + Logger.debug("๐Ÿ”’ Shell execution end detection disabled"); return; } if (event.terminal === this.activeShell) { + Logger.debug("๐Ÿ”š Active shell execution ended, will reset"); this.resetActiveShell(); } }); From c97fa09226fc350a9b6d528fd7958e92f33543f1 Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 29 Oct 2024 12:15:12 +0100 Subject: [PATCH 4/9] Add logger statements to code preview & progress --- src/previewCode.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/previewCode.ts b/src/previewCode.ts index aa1fcb67..92fa3469 100644 --- a/src/previewCode.ts +++ b/src/previewCode.ts @@ -34,6 +34,7 @@ export async function previewCode(code: string, startLine: number): Promise { + Logger.debug(`๐Ÿ“Š Command issued: ${PREVIEW_COMMAND}. Will restore clipboard`); restoreClipboard(clipboardBuffer); progress = new PreviewProgress(); }, @@ -122,6 +123,8 @@ class PreviewProgress { this.animationName = newAnimName; } + Logger.debug(`๐Ÿ“Š Progress: ${this.progress} -> ${newProgress} (${progressIncrement})`); + this.eventEmitter.emit(this.REPORT_EVENT, { increment: progressIncrement, message: newAnimName @@ -132,6 +135,7 @@ class PreviewProgress { * Finishes the progress notification, i.e. closes the progress bar. */ public finish() { + Logger.debug("๐Ÿ“Š Finishing progress notification"); this.eventEmitter.emit(this.FINISH_EVENT); } From 7c724c484f63817500010462b18aa1aaf67f4ae7 Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 29 Oct 2024 12:21:00 +0100 Subject: [PATCH 5/9] Add more log statements --- src/manimShell.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/manimShell.ts b/src/manimShell.ts index f93cf557..5f20085c 100644 --- a/src/manimShell.ts +++ b/src/manimShell.ts @@ -321,6 +321,7 @@ export class ManimShell { return; } } + Logger.debug("๐Ÿ”† User confirmed to kill active scene"); exitScene(); } this.activeShell = window.createTerminal(); @@ -355,7 +356,7 @@ export class ManimShell { * command execution. */ public resetActiveShell() { - Logger.debug("Reset active shell"); + Logger.debug("๐Ÿ’ซ Reset active shell"); this.iPythonCellCount = 0; this.activeShell = null; this.shellWeTryToSpawnIn = null; @@ -417,6 +418,8 @@ export class ManimShell { */ private exec(shell: Terminal, command: string) { this.detectShellExecutionEnd = false; + Logger.debug("๐Ÿ”’ Shell execution end detection disabled"); + if (shell.shellIntegration) { Logger.debug(`๐Ÿ’จ Sending command to terminal (with shell integration): ${command}`); shell.shellIntegration.executeCommand(command); @@ -424,7 +427,9 @@ export class ManimShell { Logger.debug(`๐Ÿ’จ Sending command to terminal (without shell integration): ${command}`); shell.sendText(command); } + this.detectShellExecutionEnd = true; + Logger.debug("๐Ÿ”“ Shell execution end detection re-enabled"); } /** @@ -548,7 +553,7 @@ export class ManimShell { } if (!this.detectShellExecutionEnd) { - Logger.debug("๐Ÿ”’ Shell execution end detection disabled"); + Logger.debug("๐Ÿ”’ Shell execution end detection disabled while end event fired"); return; } From e7c6ef86eca47779e732bd9200660d84ed311eb7 Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 29 Oct 2024 12:23:24 +0100 Subject: [PATCH 6/9] Add log statements to command waiting until finish --- src/manimShell.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/manimShell.ts b/src/manimShell.ts index 5f20085c..1325a693 100644 --- a/src/manimShell.ts +++ b/src/manimShell.ts @@ -472,7 +472,11 @@ export class ManimShell { this.eventEmitter.once(ManimShellEvent.KEYBOARD_INTERRUPT, resolve); const listener = () => { + Logger.debug("๐Ÿ•’ While waiting for command to finish" + + `, iPythonCellCount=${this.iPythonCellCount}` + + `, currentExecutionCount=${currentExecutionCount}`); if (this.iPythonCellCount > currentExecutionCount) { + Logger.debug("๐Ÿ•’ Command has finished"); this.eventEmitter.off(ManimShellEvent.IPYTHON_CELL_FINISHED, listener); resolve(); } @@ -480,6 +484,7 @@ export class ManimShell { this.eventEmitter.on(ManimShellEvent.IPYTHON_CELL_FINISHED, listener); }); if (callback) { + Logger.debug("๐Ÿ•’ Calling callback after command has finished"); callback(); } } From 56b34767b4abe1d20b037cd8989797398d0aad45 Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 29 Oct 2024 12:23:48 +0100 Subject: [PATCH 7/9] Add missing Logger import --- src/previewCode.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/previewCode.ts b/src/previewCode.ts index 92fa3469..ed38e029 100644 --- a/src/previewCode.ts +++ b/src/previewCode.ts @@ -2,6 +2,7 @@ import * as vscode from 'vscode'; import { window } from 'vscode'; import { ManimShell } from './manimShell'; import { EventEmitter } from 'events'; +import { Logger } from './logger'; const PREVIEW_COMMAND = `\x0C checkpoint_paste()\x1b`; // \x0C: is Ctrl + L From 7d37d54fda7909722db434d012dd5a0345b32b0f Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 29 Oct 2024 12:26:44 +0100 Subject: [PATCH 8/9] Add one more emoji --- src/manimShell.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/manimShell.ts b/src/manimShell.ts index 1325a693..37cc4047 100644 --- a/src/manimShell.ts +++ b/src/manimShell.ts @@ -517,8 +517,8 @@ export class ManimShell { if (data.match(MANIM_WELCOME_REGEX)) { if (this.activeShell && this.activeShell !== event.terminal) { - Logger.debug("Manim detected in new terminal, exiting old scene"); - exitScene(); // Manim detected in new terminal + Logger.debug("๐Ÿ‘‹ Manim detected in new terminal, exiting old scene"); + exitScene(); } Logger.debug("๐Ÿ‘‹ Manim welcome string detected"); this.activeShell = event.terminal; From 57c633592f6a2adffeb5042294ece2237e67b3f1 Mon Sep 17 00:00:00 2001 From: Splines Date: Tue, 29 Oct 2024 12:29:06 +0100 Subject: [PATCH 9/9] Improve terminal data output --- src/manimShell.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/manimShell.ts b/src/manimShell.ts index 37cc4047..889c929a 100644 --- a/src/manimShell.ts +++ b/src/manimShell.ts @@ -511,7 +511,7 @@ export class ManimShell { async (event: vscode.TerminalShellExecutionStartEvent) => { const stream = event.execution.read(); for await (const data of withoutAnsiCodes(stream)) { - Logger.trace(`๐Ÿงพ: ${data}`); + Logger.trace(`๐Ÿงพ Terminal data:\n${data}`); this.eventEmitter.emit(ManimShellEvent.DATA, data);