diff --git a/src/components/CustomIcon.tsx b/src/components/CustomIcon.tsx index 0b69eee8d..440ee62a4 100644 --- a/src/components/CustomIcon.tsx +++ b/src/components/CustomIcon.tsx @@ -131,6 +131,16 @@ const CustomIconMap = { /> ), + code: ( + + + + ), dimension: ( ([]) const [logs, setLogs] = useState([]) const [wasmInitFailed, setWasmInitFailed] = useState(false) + const { commandBarSend } = useCommandsContext() useEffect(() => { codeManager.registerCallBacks({ @@ -50,6 +53,28 @@ export function KclContextProvider({ }) }, []) + // Add format code to command palette. + useEffect(() => { + const commands: Command[] = [ + { + name: 'format-code', + displayName: 'Format Code', + description: 'Nicely formats the KCL code in the editor.', + needsReview: false, + groupId: 'code', + icon: 'code', + onSubmit: (data) => { + kclManager.format() + }, + }, + ] + commandBarSend({ type: 'Add commands', data: { commands } }) + + return () => { + commandBarSend({ type: 'Remove commands', data: { commands } }) + } + }, [kclManager, commandBarSend]) + return (