mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-24 08:08:15 -05:00
Fix for runtime errors
This commit is contained in:
parent
86aa4cd0fe
commit
c408196814
1 changed files with 36 additions and 33 deletions
|
@ -107,8 +107,8 @@ module.exports = class SpellView extends View
|
|||
name: 'end-current-script'
|
||||
bindKey: {win: 'Shift-Space', mac: 'Shift-Space'}
|
||||
passEvent: true # https://github.com/ajaxorg/ace/blob/master/lib/ace/keyboard/keybinding.js#L114
|
||||
# No easy way to selectively cancel shift+space, since we don't get access to the event.
|
||||
# Maybe we could temporarily set ourselves to read-only if we somehow know that a script is active?
|
||||
# No easy way to selectively cancel shift+space, since we don't get access to the event.
|
||||
# Maybe we could temporarily set ourselves to read-only if we somehow know that a script is active?
|
||||
exec: -> Backbone.Mediator.publish 'level:shift-space-pressed'
|
||||
addCommand
|
||||
name: 'end-all-scripts'
|
||||
|
@ -158,7 +158,7 @@ module.exports = class SpellView extends View
|
|||
@firepad?.dispose()
|
||||
|
||||
createFirepad: ->
|
||||
# load from firebase or the original source if there's nothing there
|
||||
# load from firebase or the original source if there's nothing there
|
||||
return if @firepadLoading
|
||||
@eventsSuppressed = true
|
||||
@loaded = false
|
||||
|
@ -330,26 +330,29 @@ module.exports = class SpellView extends View
|
|||
|
||||
# Now that that's figured out, perform the update.
|
||||
# The web worker Aether won't track state, so don't have to worry about updating it
|
||||
@clearAetherDisplay()
|
||||
workerMessage =
|
||||
function: "transpile"
|
||||
spellKey: @spell.spellKey
|
||||
source: source
|
||||
finishUpdatingAether = (aether) =>
|
||||
@displayAether aether
|
||||
@lastUpdatedAetherSpellThang = @spellThang
|
||||
@guessWhetherFinished aether if fromCodeChange
|
||||
|
||||
@clearAetherDisplay()
|
||||
if codeHasChangedSignificantly and not codeIsAsCast
|
||||
workerMessage =
|
||||
function: "transpile"
|
||||
spellKey: @spell.spellKey
|
||||
source: source
|
||||
|
||||
@worker.addEventListener "message", (e) =>
|
||||
workerData = JSON.parse e.data
|
||||
if workerData.function is "transpile" and workerData.spellKey is @spell.spellKey
|
||||
@worker.removeEventListener("message",arguments.callee, false)
|
||||
aether.problems = workerData.problems
|
||||
aether.raw = source
|
||||
finishUpdatingAether(aether)
|
||||
@worker.postMessage JSON.stringify(workerMessage)
|
||||
else
|
||||
finishUpdatingAether(aether)
|
||||
|
||||
@worker.addEventListener "message", (e) =>
|
||||
workerData = JSON.parse e.data
|
||||
if workerData.function is "transpile" and workerData.spellKey is @spell.spellKey
|
||||
@worker.removeEventListener("message",arguments.callee, false)
|
||||
aether.problems = workerData.problems
|
||||
aether.raw = source
|
||||
@displayAether aether
|
||||
@lastUpdatedAetherSpellThang = @spellThang
|
||||
@guessWhetherFinished aether if fromCodeChange
|
||||
@worker.postMessage JSON.stringify(workerMessage)
|
||||
#aether.transpile source if codeHasChangedSignificantly and not codeIsAsCast
|
||||
#@displayAether aether
|
||||
#@lastUpdatedAetherSpellThang = @spellThang
|
||||
#@guessWhetherFinished aether if fromCodeChange
|
||||
|
||||
clearAetherDisplay: ->
|
||||
problem.destroy() for problem in @problems
|
||||
|
@ -397,12 +400,12 @@ module.exports = class SpellView extends View
|
|||
#console.log "finished?", valid, endOfLine, beginningOfLine, cursorPosition, currentLine.length, aether, new Date() - 0, currentLine
|
||||
if valid and endOfLine or beginningOfLine
|
||||
@recompile()
|
||||
#console.log "recompile now!"
|
||||
#else if not valid
|
||||
# # if this works, we can get rid of all @recompileValid logic
|
||||
# console.log "not valid, but so we'll wait to do it in", @autocastDelay + "ms"
|
||||
#else
|
||||
# console.log "valid but not at end of line; recompile in", @autocastDelay + "ms"
|
||||
#console.log "recompile now!"
|
||||
#else if not valid
|
||||
# # if this works, we can get rid of all @recompileValid logic
|
||||
# console.log "not valid, but so we'll wait to do it in", @autocastDelay + "ms"
|
||||
#else
|
||||
# console.log "valid but not at end of line; recompile in", @autocastDelay + "ms"
|
||||
|
||||
onSpellChanged: (e) ->
|
||||
@spellHasChanged = true
|
||||
|
@ -438,7 +441,7 @@ module.exports = class SpellView extends View
|
|||
aether = e.world.userCodeMap[thangID]?[@spell.name] # Might not be there if this is a new Programmable Thang.
|
||||
spellThang.castAether = aether
|
||||
spellThang.aether = @spell.createAether thang
|
||||
#console.log thangID, @spell.spellKey, "ran", aether.metrics.callsExecuted, "times over", aether.metrics.statementsExecuted, "statements, with max recursion depth", aether.metrics.maxDepth, "and full flow/metrics", aether.metrics, aether.flow
|
||||
#console.log thangID, @spell.spellKey, "ran", aether.metrics.callsExecuted, "times over", aether.metrics.statementsExecuted, "statements, with max recursion depth", aether.metrics.maxDepth, "and full flow/metrics", aether.metrics, aether.flow
|
||||
@spell.transpile()
|
||||
@updateAether false, false
|
||||
|
||||
|
@ -489,7 +492,7 @@ module.exports = class SpellView extends View
|
|||
break
|
||||
_.last(executed).push state
|
||||
executedRows[state.range[0].row] = true
|
||||
#state.executing = true if state.userInfo?.time is @thang.world.age # no work
|
||||
#state.executing = true if state.userInfo?.time is @thang.world.age # no work
|
||||
currentCallIndex ?= callNumber - 1
|
||||
#console.log "got call index", currentCallIndex, "for time", @thang.world.age, "out of", states.length
|
||||
|
||||
|
@ -591,7 +594,7 @@ module.exports = class SpellView extends View
|
|||
@ace.setDisplayIndentGuides aceConfig.indentGuides # default false
|
||||
@ace.setShowInvisibles aceConfig.invisibles # default false
|
||||
@ace.setKeyboardHandler @keyBindings[aceConfig.keyBindings ? 'default']
|
||||
# @aceSession.setMode @editModes[aceConfig.language ? 'javascript']
|
||||
# @aceSession.setMode @editModes[aceConfig.language ? 'javascript']
|
||||
|
||||
onChangeLanguage: (e) ->
|
||||
aceConfig = me.get('aceConfig') ? {}
|
||||
|
|
Loading…
Reference in a new issue