diff --git a/src/livecodes/core.ts b/src/livecodes/core.ts index 1aaa723ab..1c55ee3e0 100644 --- a/src/livecodes/core.ts +++ b/src/livecodes/core.ts @@ -1166,7 +1166,6 @@ const loadConfig = async ( // load config await bootstrap(true); - await applyConfig(config); changingContent = false; @@ -3740,29 +3739,30 @@ const configureToolsPane = ( tools: Config['tools'] | undefined, mode: Config['mode'] | undefined, ) => { + if (!toolsPane) return; if (mode === 'result' && (!tools || tools.status === '' || tools.status === 'none')) { - toolsPane?.hide(); + toolsPane.hide(); return; } if (tools?.active) { - toolsPane?.setActiveTool(tools.active); + toolsPane.setActiveTool(tools.active); } if (!tools) { - toolsPane?.close(); + toolsPane.close(); return; } if (tools.status === 'none') { - toolsPane?.hide(); + toolsPane.hide(); return; } if (tools.status === 'full') { - toolsPane?.maximize(); + toolsPane.maximize(); } if (tools.status === 'open') { - toolsPane?.open(); + toolsPane.open(); } if (tools.status === 'closed' || tools.status === '') { - toolsPane?.close(); + toolsPane.close(); } // TODO: handle tools.enabled }; diff --git a/src/livecodes/languages/ruby-wasm/lang-ruby-wasm-script.ts b/src/livecodes/languages/ruby-wasm/lang-ruby-wasm-script.ts index 35fdcfd1d..53da421af 100644 --- a/src/livecodes/languages/ruby-wasm/lang-ruby-wasm-script.ts +++ b/src/livecodes/languages/ruby-wasm/lang-ruby-wasm-script.ts @@ -34,7 +34,8 @@ livecodes.rubyWasm.run = await init(hasImports(code)); const { DefaultRubyVM } = (window as any)['ruby-wasm-wasi']; const { vm } = await DefaultRubyVM(livecodes.rubyWasm.module); - vm.eval(code); + const patch = code.includes('$0') ? '$0 = __FILE__\\n' : ''; + vm.eval(patch + code); parent.postMessage({ type: 'loading', payload: false }, '*'); }); diff --git a/src/livecodes/languages/ruby/lang-ruby.ts b/src/livecodes/languages/ruby/lang-ruby.ts index b16c879ed..a91b98d8d 100644 --- a/src/livecodes/languages/ruby/lang-ruby.ts +++ b/src/livecodes/languages/ruby/lang-ruby.ts @@ -30,7 +30,8 @@ export const ruby: LanguageSpecs = { 'ruby', config, ); - return (self as any).Opal.compile(code, options); + const patch = code.includes('$0') ? '$0 = __FILE__\\n' : ''; + return (self as any).Opal.compile(patch + code, options); }; }, scripts: ({ compiled, config }) => {