Merge pull request #42 from OpenPipe/autoformat

implement format on save
This commit is contained in:
Kyle Corbitt
2023-07-14 12:56:41 -07:00
committed by GitHub
4 changed files with 49 additions and 13 deletions

View File

@@ -27,11 +27,16 @@ export default function VariantConfigEditor(props: { variant: PromptVariant }) {
const toast = useToast();
const [onSave] = useHandledAsyncCallback(async () => {
const currentFn = editorRef.current?.getValue();
if (!editorRef.current) return;
await editorRef.current.getAction("editor.action.formatDocument")?.run();
const currentFn = editorRef.current.getValue();
if (!currentFn) return;
// Check if the editor has any typescript errors
const model = editorRef.current?.getModel();
const model = editorRef.current.getModel();
if (!model) return;
const markers = monaco?.editor.getModelMarkers({ resource: model.uri });