From 9b9df12ea0efa05c61b1a020d75a3e322c76bb8a Mon Sep 17 00:00:00 2001 From: Nick Winter <livelily@gmail.com> Date: Fri, 24 Jan 2014 08:01:00 -0800 Subject: [PATCH] Huge Aether performance fix; spells now scroll while debugging. --- app/views/play/level/tome/spell.coffee | 2 +- app/views/play/level/tome/spell_toolbar_view.coffee | 8 ++++++++ app/views/play/level/tome/spell_view.coffee | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/play/level/tome/spell.coffee b/app/views/play/level/tome/spell.coffee index 84f6cd906..46b3fc95c 100644 --- a/app/views/play/level/tome/spell.coffee +++ b/app/views/play/level/tome/spell.coffee @@ -56,7 +56,7 @@ module.exports = class Spell createAether: (thang) -> aetherOptions = - thisValue: thang.createUserContext() + #thisValue: thang.createUserContext() # slooow, and not useful I guess? problems: jshint_W040: {level: "ignore"} aether_MissingThis: {level: (if thang.requiresThis then 'error' else 'warning')} diff --git a/app/views/play/level/tome/spell_toolbar_view.coffee b/app/views/play/level/tome/spell_toolbar_view.coffee index 16870f85f..d84545838 100644 --- a/app/views/play/level/tome/spell_toolbar_view.coffee +++ b/app/views/play/level/tome/spell_toolbar_view.coffee @@ -63,6 +63,7 @@ module.exports = class SpellToolbarView extends View @setStatementRatio e.offsetX / @$el.find('.progress').width() @updateTime() @maintainIndexHover = true + @updateScroll() onProgressMouseOut: (e) -> @maintainIndexHover = false @@ -73,6 +74,7 @@ module.exports = class SpellToolbarView extends View lastTime = @statementTime @setStatementIndex @statementIndex + delta @updateTime() if @statementIndex isnt lastTime + @updateScroll() updateTime: -> @maintainIndexScrub = true @@ -80,6 +82,12 @@ module.exports = class SpellToolbarView extends View @maintainIndexScrubTimeout = _.delay (=> @maintainIndexScrub = false), 500 Backbone.Mediator.publish 'level-set-time', time: @statementTime, scrubDuration: 500 + updateScroll: -> + return unless statementStart = @callState?.statements?[@statementIndex]?.range[0] + text = @ace.getValue() + currentLine = text.substr(0, statementStart).split('\n').length - 1 + @ace.scrollToLine currentLine, true, true + setCallState: (callState, statementIndex, @callIndex, @metrics) -> return if callState is @callState and statementIndex is @statementIndex return unless @callState = callState diff --git a/app/views/play/level/tome/spell_view.coffee b/app/views/play/level/tome/spell_view.coffee index f648ab9c8..bcd960452 100644 --- a/app/views/play/level/tome/spell_view.coffee +++ b/app/views/play/level/tome/spell_view.coffee @@ -69,6 +69,7 @@ module.exports = class SpellView extends View @ace.setShowPrintMargin false @ace.setShowInvisibles false @ace.setBehavioursEnabled false + @ace.setAnimatedScroll true @toggleControls null, @writable @aceSession.selection.on 'changeCursor', @onCursorActivity $(@ace.container).find('.ace_gutter').on 'click', '.ace_error, .ace_warning, .ace_info', @onAnnotationClick @@ -461,6 +462,7 @@ module.exports = class SpellView extends View markerRange.id = @aceSession.addMarker markerRange, clazz, "text" @markerRanges.push markerRange @aceSession.addGutterDecoration start.row, clazz if clazz is 'executing' + null onAnnotationClick: -> alertBox = $("<div class='alert alert-info fade in'>#{msg}</div>")