From 0b8cc06019bc8b75ac712a9a52ab592b9cafb239 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 8 May 2015 14:57:38 +0400 Subject: [PATCH] fix +7206 pressing pagedown screws up the layout of ace trees --- .../ace_tree/lib/ace_tree/virtual_renderer.js | 62 ++++++++++++------- package.json | 3 +- plugins/c9.ide.keys/commands.js | 2 +- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/node_modules/ace_tree/lib/ace_tree/virtual_renderer.js b/node_modules/ace_tree/lib/ace_tree/virtual_renderer.js index 031237ef..68cab1c1 100644 --- a/node_modules/ace_tree/lib/ace_tree/virtual_renderer.js +++ b/node_modules/ace_tree/lib/ace_tree/virtual_renderer.js @@ -839,31 +839,45 @@ var VirtualRenderer = function(container, cellWidth, cellHeight) { this.animateScrolling = function(fromValue, callback) { var toValue = this.scrollTop; - if (this.$animatedScroll && Math.abs(fromValue - toValue) < 100000) { - var _self = this; - var steps = _self.$calcSteps(fromValue, toValue); - this.$inScrollAnimation = true; - - clearInterval(this.$timer); - - _self.provider.setScrollTop(steps.shift()); - this.$timer = setInterval(function() { - if (steps.length) { - _self.setScrollTop(steps.shift()); - // trick provider to think it's already scrolled to not loose toValue - _self.scrollTop = toValue; - } else if (toValue != null) { - _self.scrollTop = -1; - _self.setScrollTop(toValue); - toValue = null; - } else { - // do this on separate step to not get spurious scroll event from scrollbar - _self.$timer = clearInterval(_self.$timer); - _self.$inScrollAnimation = false; - callback && callback(); - } - }, 10); + if (!this.$animatedScroll) + return; + var _self = this; + + if (fromValue == toValue) + return; + + if (this.$scrollAnimation) { + var oldSteps = this.$scrollAnimation.steps; + if (oldSteps.length) { + fromValue = oldSteps[0]; + if (fromValue == toValue) + return; + } } + + var steps = _self.$calcSteps(fromValue, toValue); + this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps}; + + clearInterval(this.$timer); + + _self.provider.setScrollTop(steps.shift()); + // trick provider to think it's already scrolled to not loose toValue + _self.provider.$scrollTop = toValue; + this.$timer = setInterval(function() { + if (steps.length) { + _self.provider.setScrollTop(steps.shift()); + _self.provider.$scrollTop = toValue; + } else if (toValue != null) { + _self.provider.$scrollTop = -1; + _self.provider.setScrollTop(toValue); + toValue = null; + } else { + // do this on separate step to not get spurious scroll event from scrollbar + _self.$timer = clearInterval(_self.$timer); + _self.$scrollAnimation = null; + callback && callback(); + } + }, 10); }; /** diff --git a/package.json b/package.json index 8359cad2..46478ee1 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ }, "dependencies": { "acorn": ">=0.11.0", - "amd-loader": "", "async": "^0.9.0", "base64id": "~0.1.0", "c9": "", @@ -85,7 +84,7 @@ "c9.ide.immediate": "#6845a93705", "c9.ide.installer": "#e3bf6fe625", "c9.ide.mount": "#32e79866ee", - "c9.ide.navigate": "#64156c7f4a", + "c9.ide.navigate": "#7c58c7f3d7", "c9.ide.newresource": "#f1f0624768", "c9.ide.openfiles": "#28a4f5af16", "c9.ide.preview": "#0bd8dd6e8c", diff --git a/plugins/c9.ide.keys/commands.js b/plugins/c9.ide.keys/commands.js index 2f8e7fda..7d6b8a26 100644 --- a/plugins/c9.ide.keys/commands.js +++ b/plugins/c9.ide.keys/commands.js @@ -245,7 +245,7 @@ define(function(require, exports, module) { function setDefault(name, keys) { var command = commands[name]; - + if (!command) return; // If bind key is not yet overridden by a custom one if (plugin.commandManager[name] == command.bindKey[platform]) bindKey(keys[platform], command);