diff --git a/src/components/DebugControls.tsx b/src/components/DebugControls.tsx index 154c567..926e300 100644 --- a/src/components/DebugControls.tsx +++ b/src/components/DebugControls.tsx @@ -1,17 +1,17 @@ import { Button } from "@/components/ui/button"; import { Toggle } from "@/components/ui/toggle"; -import { - Play, - SkipForward, - ArrowDown, - ArrowUp, - RotateCw, - Square, +import { + Play, + SkipForward, + ArrowDown, + ArrowUp, + RotateCw, + Square, ToggleRight } from "lucide-react"; import { cn } from "@/lib/utils"; -import { +import { Tooltip, TooltipContent, TooltipProvider, @@ -27,7 +27,7 @@ interface DebugControlsProps { className?: string; } -export function DebugControls({ +export function DebugControls({ isDebugging, isPaused, onDebugAction, @@ -36,37 +36,26 @@ export function DebugControls({ return (
- - - onDebugAction("toggle")} - aria-label="Toggle debug mode" - className="gap-1" - > - - - {!isDebugging ? "Debug Mode" : "Run Mode"} - - - - -

Debug Mode

-
-
- + + {isDebugging && ( <>
- + -
diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index ec13982..cc95451 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -57,7 +57,9 @@ const Index = () => { // Assign all the callbacks -------------------------------------------- pythonThread.callbackBreakHit = (line: number) => { - codeEditorRef.current?.highlightExecutionLine(line); + if (isDebugging) { + codeEditorRef.current?.highlightExecutionLine(line); + } } pythonThread.callbackStdout = (outputText: string) => { setOutput(prev => prev + outputText); @@ -69,6 +71,7 @@ const Index = () => { } pythonThread.callbackExecEnd = () => { setIsRunning(false); + setIsPaused(false); codeEditorRef.current?.clearExecutionLine(); } @@ -84,6 +87,9 @@ const Index = () => { try { setIsRunning(true); pythonThread.startExecution(code); + if (isDebugging) { + setIsPaused(true); + } } catch (error) { console.error("Error running Jac code:", error); setOutput(`Error: ${error}`); @@ -120,15 +126,18 @@ const Index = () => { useEffect(() => { if (pythonThread != null && pythonThread.loaded) { - pythonThread.setBreakpoints(breakpoints); + if (isDebugging) { + pythonThread.setBreakpoints(breakpoints); + } else { + pythonThread.setBreakpoints([]); + } } - }, [breakpoints, pythonThread]); + }, [breakpoints, pythonThread, isDebugging]); const handleDebugAction = useCallback(async (action: DebugAction) => { switch (action) { - // Toggles between debug and run mode. case "toggle": setIsDebugging(prev => { @@ -225,7 +234,7 @@ const Index = () => {