diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index abaa106f..5a86e6aa 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -263,6 +263,11 @@ exports.commands = [{ bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"), exec: function(editor) { editor.commands.replay(editor); }, readOnly: true +}, { + name: "jumptomatching", + bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"), + exec: function(editor) { editor.jumpToMatching(); }, + readOnly: true }, // commands disabled in readOnly mode @@ -381,10 +386,6 @@ exports.commands = [{ name: "tolowercase", bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"), exec: function(editor) { editor.toLowerCase(); } -}, { - name: "jumptomatching", - bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"), - exec: function(editor) { editor.jumpToMatching(); } }]; }); diff --git a/lib/ace/edit_session/folding.js b/lib/ace/edit_session/folding.js index 9c3562db..36565555 100644 --- a/lib/ace/edit_session/folding.js +++ b/lib/ace/edit_session/folding.js @@ -625,7 +625,7 @@ function Folding() { this.foldAll = function(startRow, endRow) { var foldWidgets = this.foldWidgets; - endRow = endRow || foldWidgets.length; + endRow = endRow || this.getLength(); for (var row = startRow || 0; row < endRow; row++) { if (foldWidgets[row] == null) foldWidgets[row] = this.getFoldWidget(row); diff --git a/lib/ace/editor.js b/lib/ace/editor.js index dd38d67d..b003146f 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -221,6 +221,7 @@ var Editor = function(renderer, session) { this.setFontSize = function(size) { this.container.style.fontSize = size; + this.renderer.updateFontSize(); }; this.$highlightBrackets = function() { @@ -1205,8 +1206,7 @@ var Editor = function(renderer, session) { var range = this.$search.find(this.session); if (range) { this.session.unfold(range); - this.gotoLine(range.end.row+1, range.end.column); - this.selection.setSelectionRange(range); + this.selection.setSelectionRange(range); // this scrolls selection into view } }; diff --git a/lib/ace/layer/cursor.js b/lib/ace/layer/cursor.js index 811d5df0..5fa7644a 100644 --- a/lib/ace/layer/cursor.js +++ b/lib/ace/layer/cursor.js @@ -93,7 +93,7 @@ var Cursor = function(parentEl) { }, 1000); }; - this.getPixelPosition = function(onScreen) { + this.getPixelPosition = function(position, onScreen) { if (!this.config || !this.session) { return { left : 0, @@ -101,7 +101,8 @@ var Cursor = function(parentEl) { }; } - var position = this.session.selection.getCursor(); + if (!position) + position = this.session.selection.getCursor(); var pos = this.session.documentToScreenPosition(position); var cursorLeft = Math.round(this.$padding + pos.column * this.config.characterWidth); @@ -117,7 +118,7 @@ var Cursor = function(parentEl) { this.update = function(config) { this.config = config; - this.pixelPos = this.getPixelPosition(true); + this.pixelPos = this.getPixelPosition(null, true); this.cursor.style.left = this.pixelPos.left + "px"; this.cursor.style.top = this.pixelPos.top + "px"; diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index e6981165..69e917ae 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -84,7 +84,7 @@ var Text = function(parentEl) { var size = this.$measureSizes(); if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) { this.$characterSize = size; - this._emit("changeCharaterSize", {data: size}); + this._emit("changeCharacterSize", {data: size}); } }; diff --git a/lib/ace/placeholder.js b/lib/ace/placeholder.js index 4b5ba4e7..f0fa5b46 100644 --- a/lib/ace/placeholder.js +++ b/lib/ace/placeholder.js @@ -117,6 +117,8 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) var range = delta.range; if(range.start.row !== range.end.row) return; if(range.start.row !== this.pos.row) return; + if (this.$updating) return; + this.$updating = true; var lengthDiff = delta.action === "insertText" ? range.end.column - range.start.column : range.start.column - range.end.column; if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) { @@ -169,9 +171,11 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) this.others[i]._emit("change", {value: this.others[i]}); } } + this.$updating = false; }; this.onCursorChange = function(event) { + if (this.$updating) return; var pos = this.session.selection.getCursor(); if(pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) { this.showOtherMarkers(); diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 260525d0..a195e372 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -118,7 +118,7 @@ var VirtualRenderer = function(container, theme) { column : 0 }; - this.$textLayer.addEventListener("changeCharaterSize", function() { + this.$textLayer.addEventListener("changeCharacterSize", function() { _self.characterWidth = textLayer.getCharacterWidth(); _self.lineHeight = textLayer.getLineHeight(); _self.$updatePrintMargin(); @@ -171,6 +171,7 @@ var VirtualRenderer = function(container, theme) { this.CHANGE_MARKER_BACK = 128; this.CHANGE_MARKER_FRONT = 256; this.CHANGE_FULL = 512; + this.CHANGE_H_SCROLL = 1024; oop.implement(this, EventEmitter); @@ -476,6 +477,11 @@ var VirtualRenderer = function(container, theme) { if (changes & this.CHANGE_SIZE) this.$updateScrollBar(); + + if (changes & this.CHANGE_H_SCROLL) { + //this.content.style.left = -this.scrollLeft + "px"; + this.scroller.scrollLeft = this.scrollLeft + } }; this.$computeLayerConfig = function() { @@ -542,12 +548,6 @@ var VirtualRenderer = function(container, theme) { this.content.style.width = longestLine + 2 * this.$padding + "px"; this.content.style.height = minHeight + "px"; - // scroller.scrollWidth was smaller than scrollLeft we needed - if (this.$desiredScrollLeft) { - this.scrollToX(this.$desiredScrollLeft); - this.$desiredScrollLeft = 0; - } - // Horizontal scrollbar visibility may have changed, which changes // the client height of the scroller if (horizScrollChanged) @@ -653,14 +653,11 @@ var VirtualRenderer = function(container, theme) { if (scrollLeft > left) { if (left < this.$padding + 2 * this.layerConfig.characterWidth) left = 0; - this.scrollToX(left); + this.session.setScrollLeft(left); } if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) { - if (left > this.layerConfig.width + 2 * this.$padding) - this.$desiredScrollLeft = left; - else - this.scrollToX(Math.round(left + this.characterWidth - this.$size.scrollerWidth)); + this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth)); } }; @@ -685,15 +682,11 @@ var VirtualRenderer = function(container, theme) { }; this.scrollToLine = function(line, center) { - var lineHeight = { lineHeight: this.lineHeight }; - var offset = 0; - for (var l = 1; l < line; l++) { - offset += this.session.getRowHeight(lineHeight, l-1); - } - - if (center) { + var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0}); + var offset = pos.top; + if (center) offset -= this.$size.scrollerHeight / 2; - } + this.session.setScrollTop(offset); }; @@ -710,8 +703,10 @@ var VirtualRenderer = function(container, theme) { if (scrollLeft <= this.$padding) scrollLeft = 0; - this.scroller.scrollLeft = scrollLeft; - scrollLeft = this.scroller.scrollLeft; + if (this.scrollLeft !== scrollLeft) { + this.$loop.schedule(this.CHANGE_H_SCROLL); + this.scrollLeft = scrollLeft; + } }; this.scrollBy = function(deltaX, deltaY) {