Default to using hero unless self/this is present in the player's code.

This affects the autocomplete and spell palette api docs.
This commit is contained in:
Cat Sync 2016-05-09 12:49:25 -04:00
parent 0edd8af1db
commit 50c8588231
2 changed files with 2 additions and 2 deletions
app/views/play/level/tome

View file

@ -532,7 +532,7 @@ module.exports = class SpellView extends CocoView
# For now, update autocomplete to use hero instead of self/this, if hero is already used in the source.
# Later, we should make this happen all the time - or better yet update the snippets.
source = @getSource()
if /hero/.test(source)
if not /(self[\.\:]|this\.|\@)/.test(source)
thisToken =
'python': /self/,
'javascript': /this/,

View file

@ -218,7 +218,7 @@ module.exports = class TomeView extends CocoView
updateSpellPalette: (thang, spell) ->
return unless thang and @spellPaletteView?.thang isnt thang and thang.programmableProperties or thang.apiProperties
useHero = /hero/.test(spell.getSource())
useHero = not /(self[\.\:]|this\.|\@)/.test(spell.getSource())
@spellPaletteView = @insertSubView new SpellPaletteView thang: thang, supermodel: @supermodel, programmable: spell?.canRead(), language: spell?.language ? @options.session.get('codeLanguage'), session: @options.session, level: @options.level, courseID: @options.courseID, courseInstanceID: @options.courseInstanceID, useHero: useHero
@spellPaletteView.toggleControls {}, spell.view.controlsEnabled if spell?.view # TODO: know when palette should have been disabled but didn't exist