@@ -1116,6 +1116,7 @@ module ControlPanel = {
1116
1116
~state : CompilerManagerHook .state ,
1117
1117
~dispatch : CompilerManagerHook .action => unit ,
1118
1118
~editorCode : React .ref <string >,
1119
+ ~setCurrentTab : (tab => tab ) => unit ,
1119
1120
) => {
1120
1121
let children = switch state {
1121
1122
| Init => React .string ("Initializing..." )
@@ -1135,12 +1136,17 @@ module ControlPanel = {
1135
1136
| _ => false
1136
1137
}
1137
1138
1139
+ let runCode = () => {
1140
+ setCurrentTab (_ => Output )
1141
+ dispatch (RunCode )
1142
+ }
1143
+
1138
1144
let onKeyDown = event => {
1139
1145
switch (
1140
1146
event -> ReactEvent .Keyboard .metaKey || event -> ReactEvent .Keyboard .ctrlKey ,
1141
1147
event -> ReactEvent .Keyboard .key ,
1142
1148
) {
1143
- | (true , "e" ) => dispatch ( RunCode )
1149
+ | (true , "e" ) => runCode ( )
1144
1150
| _ => ()
1145
1151
}
1146
1152
}
@@ -1163,10 +1169,18 @@ module ControlPanel = {
1163
1169
}
1164
1170
1165
1171
<div className = "flex flex-row gap-x-2" >
1166
- <ToggleButton checked = autoRun onChange = {_ => dispatch (ToggleAutoRun )}>
1172
+ <ToggleButton
1173
+ checked = autoRun
1174
+ onChange = {_ => {
1175
+ switch state {
1176
+ | Ready ({autoRun : false }) => setCurrentTab (_ => Output )
1177
+ | _ => ()
1178
+ }
1179
+ dispatch (ToggleAutoRun )
1180
+ }}>
1167
1181
{React .string ("Auto-run" )}
1168
1182
</ToggleButton >
1169
- <Button onClick = {_ => dispatch ( RunCode )}> {React .string (runButtonText )} </Button >
1183
+ <Button onClick = {_ => runCode ( )}> {React .string (runButtonText )} </Button >
1170
1184
<Button onClick = onFormatClick > {React .string ("Format" )} </Button >
1171
1185
<ShareButton actionIndicatorKey />
1172
1186
</div >
@@ -1671,6 +1685,7 @@ let make = (~versions: array<string>) => {
1671
1685
state = compilerState
1672
1686
dispatch = compilerDispatch
1673
1687
editorCode
1688
+ setCurrentTab
1674
1689
/>
1675
1690
<div
1676
1691
className = {` flex ${layout == Column ? "flex-col" : "flex-row" }` }
0 commit comments