From 2d714e63b1f4dcd4c4cf7200ea3bff735f6ce372 Mon Sep 17 00:00:00 2001 From: Santhosh mani Date: Sat, 21 Dec 2024 14:53:14 +0530 Subject: [PATCH] feat: Add Keyboard shortcut to Clear Console --- src/renderer/components/output.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/renderer/components/output.tsx b/src/renderer/components/output.tsx index 9185929e81..616878a866 100644 --- a/src/renderer/components/output.tsx +++ b/src/renderer/components/output.tsx @@ -91,6 +91,23 @@ export const Output = observer( openerService: this.openerService(), }, ); + if (this.editor) { + // Register Command (⌘) + K to clear the console on MacOs, + // Ctrl + K on other systems, such as Windows and Linux + this.editor.addCommand( + MonacoType.KeyMod.CtrlCmd | MonacoType.KeyCode.KEY_K, + () => { + if (this.model || this.props.appState.output.length > 0) { + this.props.appState.clearConsole(); + this.outputRef.current?.scrollTo(0, 0); + this.props.appState.output.push({ + timeString: new Date().toLocaleTimeString(), + text: '', + }); + } + }, + ); + } } }