From af8d1330fd73d07eba15852fabc303926092f927 Mon Sep 17 00:00:00 2001 From: Andrew Varga Date: Fri, 13 Jun 2025 15:56:18 +0200 Subject: [PATCH] move useHotkey for undo/redo into App --- src/App.tsx | 11 +++++++++++ .../ModelingSidebar/ModelingPanes/KclEditorPane.tsx | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 710cd213a..81d7ab89c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -29,6 +29,7 @@ import { codeManager, kclManager, settingsActor, + editorManager, } from '@src/lib/singletons' import { maybeWriteToDisk } from '@src/lib/telemetry' import type { IndexLoaderData } from '@src/lib/types' @@ -94,6 +95,16 @@ export function App() { useHotkeys('backspace', (e) => { e.preventDefault() }) + // Since these already exist in the editor, we don't need to define them + // with the wrapper. + useHotkeys('mod+z', (e) => { + e.preventDefault() + editorManager.undo() + }) + useHotkeys('mod+shift+z', (e) => { + e.preventDefault() + editorManager.redo() + }) useHotkeyWrapper( [isDesktop() ? 'mod + ,' : 'shift + mod + ,'], () => navigate(filePath + PATHS.SETTINGS), diff --git a/src/components/ModelingSidebar/ModelingPanes/KclEditorPane.tsx b/src/components/ModelingSidebar/ModelingPanes/KclEditorPane.tsx index c45d38598..95b9ad8b0 100644 --- a/src/components/ModelingSidebar/ModelingPanes/KclEditorPane.tsx +++ b/src/components/ModelingSidebar/ModelingPanes/KclEditorPane.tsx @@ -75,17 +75,6 @@ export const KclEditorPane = () => { : context.app.theme.current const { copilotLSP, kclLSP } = useLspContext() - // Since these already exist in the editor, we don't need to define them - // with the wrapper. - useHotkeys('mod+z', (e) => { - e.preventDefault() - editorManager.undo() - }) - useHotkeys('mod+shift+z', (e) => { - e.preventDefault() - editorManager.redo() - }) - // When this component unmounts, we need to tell the machine that the editor useEffect(() => { return () => {