Enable updated autocomplete

Bug fixes for incorrect autocompletes such as “this.this.moveRight()();”
Reducing suggestions to just level snippets to make it more beginner
friendly.
This commit is contained in:
Matt Lott 2014-10-07 15:08:27 -07:00
parent ff467d1f31
commit 1108159603
2 changed files with 21 additions and 9 deletions

View file

@ -100,11 +100,7 @@ module.exports = class SpellView extends CocoView
@toggleControls null, @writable
@aceSession.selection.on 'changeCursor', @onCursorActivity
$(@ace.container).find('.ace_gutter').on 'click', '.ace_error, .ace_warning, .ace_info', @onAnnotationClick
# TODO: restore Zatanna when it totally stops the this.this.moveRight()(); problem
#@zatanna = new Zatanna @ace,
# liveCompletion: aceConfig.liveCompletion ? true
# completers:
# keywords: false
@initAutocomplete aceConfig.liveCompletion ? true
createACEShortcuts: ->
@aceCommands = aceCommands = []
@ -191,8 +187,24 @@ module.exports = class SpellView extends CocoView
@aceSession.setUndoManager(new UndoManager())
@ace.clearSelection()
initAutocomplete: (@autocomplete) ->
# TODO: Turn on more autocompletion based on level sophistication
# TODO: E.g. using the language default snippets yields a bunch of crazy non-beginner suggestions
# TODO: Options logic shouldn't exist both here and in updateAutocomplete()
@zatanna = new Zatanna @ace,
basic: false
liveCompletion: false
snippets: @autocomplete
snippetsLangDefaults: false
completers:
keywords: false
text: false
updateAutocomplete: (@autocomplete) ->
@zatanna?.set 'snippets', @autocomplete
addZatannaSnippets: (e) ->
return unless @zatanna
return unless @zatanna and @autocomplete
snippetEntries = []
for owner, props of e.propGroups
for prop in props
@ -682,12 +694,12 @@ module.exports = class SpellView extends CocoView
@ace.setDisplayIndentGuides aceConfig.indentGuides # default false
@ace.setShowInvisibles aceConfig.invisibles # default false
@ace.setKeyboardHandler @keyBindings[aceConfig.keyBindings ? 'default']
@zatanna?.set 'liveCompletion', (aceConfig.liveCompletion ? false)
@updateAutocomplete(aceConfig.liveCompletion ? false)
onChangeLanguage: (e) ->
return unless @spell.canWrite()
@aceSession.setMode @editModes[e.language]
# @zatanna?.set 'language', @editModes[e.language].substr('ace/mode/')
@zatanna?.set 'language', @editModes[e.language].substr('ace/mode/')
wasDefault = @getSource() is @spell.originalSource
@spell.setLanguage e.language
@reloadCode true if wasDefault

View file

@ -44,7 +44,7 @@
"bootstrap": "~3.2.0",
"validated-backbone-mediator": "~0.1.3",
"jquery.browser": "~0.0.6",
"zatanna": "~0.0.6",
"zatanna": "https://github.com/differentmatt/zatanna.git#master",
"modernizr": "~2.8.3",
"backfire": "~0.3.0"
},