Timothy J. Baek 7 hónapja
szülő
commit
913620ff0c

+ 5 - 1
src/lib/components/common/CodeEditor.svelte

@@ -14,7 +14,7 @@
 
 	import { oneDark } from '@codemirror/theme-one-dark';
 
-	import { onMount, createEventDispatcher, getContext } from 'svelte';
+	import { onMount, createEventDispatcher, getContext, tick } from 'svelte';
 
 	import { formatPythonCode } from '$lib/apis/utils';
 	import { toast } from 'svelte-sonner';
@@ -66,6 +66,10 @@
 					changes: [{ from: 0, to: codeEditor.state.doc.length, insert: formattedCode }]
 				});
 
+				_value = formattedCode;
+				dispatch('change', { value: _value });
+				await tick();
+
 				toast.success($i18n.t('Code formatted successfully'));
 				return true;
 			}

+ 4 - 0
src/lib/components/workspace/Functions/FunctionEditor.svelte

@@ -267,6 +267,10 @@ class Pipe:
 			await tick();
 
 			const res = await codeEditor.formatPythonCodeHandler();
+			await tick();
+
+			content = _content;
+			await tick();
 
 			if (res) {
 				console.log('Code formatted successfully');

+ 4 - 0
src/lib/components/workspace/Tools/ToolkitEditor.svelte

@@ -155,6 +155,10 @@ class Tools:
 			await tick();
 
 			const res = await codeEditor.formatPythonCodeHandler();
+			await tick();
+
+			content = _content;
+			await tick();
 
 			if (res) {
 				console.log('Code formatted successfully');