diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 3c2d29b1..330de870 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -48,7 +48,7 @@ canon.addCommand({ canon.addCommand({ name: "selectall", - exec: function(env, args, request) { env.editor.getSelection().selectAll(); } + exec: function(env, args, request) { env.editor.selectAll(); } }); canon.addCommand({ name: "removeline", diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 8d66ad8a..dbcb7c44 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -73,7 +73,7 @@ var Editor =function(renderer, session) { this.$selectionMarker = null; this.$highlightLineMarker = null; - this.$blockScrolling = false; + this.$blockScrolling = 0; this.$search = new Search().set({ wrap: true @@ -285,7 +285,7 @@ var Editor =function(renderer, session) { this.onCursorChange = function(e) { this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite); - if (!this.$blockScrolling && (!e || !e.blockScrolling)) { + if (!this.$blockScrolling) { this.renderer.scrollCursorIntoView(); } @@ -459,9 +459,9 @@ var Editor =function(renderer, session) { this.$overwrite = overwrite; - this.$blockScrolling = true; + this.$blockScrolling += 1; this.onCursorChange(); - this.$blockScrolling = false; + this.$blockScrolling -= 1; this._dispatchEvent("changeOverwrite", {data: overwrite}); }; @@ -778,6 +778,13 @@ var Editor =function(renderer, session) { return this.selection.getRange(); }; + + this.selectAll = function() { + this.$blockScrolling += 1; + this.selection.selectAll(); + this.$blockScrolling -= 1; + }; + this.clearSelection = function() { this.selection.clearSelection(); }; @@ -794,9 +801,9 @@ var Editor =function(renderer, session) { this.gotoLine = function(lineNumber, row) { this.selection.clearSelection(); - this.$blockScrolling = true; + this.$blockScrolling += 1; this.moveCursorTo(lineNumber-1, row || 0); - this.$blockScrolling = false; + this.$blockScrolling -= 1; if (!this.isRowVisible(this.getCursorPosition().row)) { this.scrollToRow(lineNumber - 1 - Math.floor(this.getVisibleRowCount() / 2)); diff --git a/lib/ace/selection.js b/lib/ace/selection.js index 8e6d4b73..12453a3e 100644 --- a/lib/ace/selection.js +++ b/lib/ace/selection.js @@ -160,8 +160,7 @@ var Selection = function(session) { this.selectAll = function() { var lastRow = this.doc.getLength() - 1; this.setSelectionAnchor(lastRow, this.doc.getLine(lastRow).length); - this.setSelectionLead(0, 0); -// this._dispatchEvent("changeSelection", {blockScrolling: true}); + this.moveCursorTo(0, 0); }; this.setSelectionRange = function(range, reverse) {