move useHotkey for undo/redo into App

This commit is contained in:
Andrew Varga
2025-06-13 15:56:18 +02:00
parent 939c2c77b0
commit af8d1330fd
2 changed files with 11 additions and 11 deletions

View File

@ -29,6 +29,7 @@ import {
codeManager, codeManager,
kclManager, kclManager,
settingsActor, settingsActor,
editorManager,
} from '@src/lib/singletons' } from '@src/lib/singletons'
import { maybeWriteToDisk } from '@src/lib/telemetry' import { maybeWriteToDisk } from '@src/lib/telemetry'
import type { IndexLoaderData } from '@src/lib/types' import type { IndexLoaderData } from '@src/lib/types'
@ -94,6 +95,16 @@ export function App() {
useHotkeys('backspace', (e) => { useHotkeys('backspace', (e) => {
e.preventDefault() 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( useHotkeyWrapper(
[isDesktop() ? 'mod + ,' : 'shift + mod + ,'], [isDesktop() ? 'mod + ,' : 'shift + mod + ,'],
() => navigate(filePath + PATHS.SETTINGS), () => navigate(filePath + PATHS.SETTINGS),

View File

@ -75,17 +75,6 @@ export const KclEditorPane = () => {
: context.app.theme.current : context.app.theme.current
const { copilotLSP, kclLSP } = useLspContext() 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 // When this component unmounts, we need to tell the machine that the editor
useEffect(() => { useEffect(() => {
return () => { return () => {