From 4d72fb918405a281632a9cf4e1443963de914e1d Mon Sep 17 00:00:00 2001 From: Asier Isayas Date: Tue, 18 Feb 2025 14:38:22 -0500 Subject: [PATCH] Close terminal when Ctrl key is pressed --- src/Terminal/JupyterLabAppFactory.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Terminal/JupyterLabAppFactory.ts b/src/Terminal/JupyterLabAppFactory.ts index 2ad61b294..b37dd9aa1 100644 --- a/src/Terminal/JupyterLabAppFactory.ts +++ b/src/Terminal/JupyterLabAppFactory.ts @@ -17,7 +17,7 @@ export class JupyterLabAppFactory { if (userContext.apiType === "VCoreMongo" && content?.includes("MongoServerError: Invalid key")) { this.restartShell = true; } - return content?.includes("cosmosuser@"); + return content?.includes("cosmosshelluser@"); } private isMongoShellStarted(content: string | undefined) { @@ -68,7 +68,6 @@ export class JupyterLabAppFactory { const session = await manager.startNew(); session.messageReceived.connect(async (_, message: IMessage) => { const content = message.content && message.content[0]?.toString(); - if (this.checkShellStarted && message.type == "stdout") { //Close the terminal tab once the shell closed messages are received if (!this.isShellStarted) { @@ -114,6 +113,13 @@ export class JupyterLabAppFactory { panel.dispose(); }); + // Close terminal when Ctrl key is pressed + term.node.addEventListener('keydown', (event: KeyboardEvent) => { + if (event.ctrlKey) { + this.onShellExited(false); + } + }); + return session; } }