diff --git a/lib/ace/anchor.js b/lib/ace/anchor.js index 48885e51..f0a02183 100644 --- a/lib/ace/anchor.js +++ b/lib/ace/anchor.js @@ -1,5 +1,4 @@ -/* vim:ts=4:sts=4:sw=4: - * ***** BEGIN LICENSE BLOCK ***** +/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version @@ -71,9 +70,6 @@ var Anchor = exports.Anchor = function(doc, row, column) { this.onChange = function(e) { var delta = e.data; - if (delta.isMeta) - return; - var range = delta.range; if (range.start.row == range.end.row && range.start.row != this.row) diff --git a/lib/ace/document.js b/lib/ace/document.js index 51f848ca..3fd06c53 100644 --- a/lib/ace/document.js +++ b/lib/ace/document.js @@ -1,5 +1,4 @@ -/* vim:ts=4:sts=4:sw=4: - * ***** BEGIN LICENSE BLOCK ***** +/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version @@ -21,7 +20,6 @@ * * Contributor(s): * Fabian Jakobs - * Mihai Sucan * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -365,59 +363,9 @@ var Document = function(text) { return end; }; - /** - * Move a range of text from the given range to the given position. - * - * @param fromRange {Range} The range of text you want moved within the - * document. - * @param toPosition {Object} The location (row and column) where you want - * to move the text to. - * @return {Range} The new range where the text was moved to. - */ - this.move = function(fromRange, toPosition) { - var text = this.getTextRange(fromRange); - this.remove(fromRange); - - var toRow = toPosition.row; - var toColumn = toPosition.column; - - // Make sure to update the insert location, when text is removed in - // front of the chosen point of insertion. - if (!fromRange.isMultiLine() && fromRange.start.row == toRow && - fromRange.end.column < toColumn) - toColumn -= text.length; - - if (fromRange.isMultiLine() && fromRange.end.row < toRow) { - var lines = this.$split(text); - toRow -= lines.length - 1; - } - - var endRow = toRow + fromRange.end.row - fromRange.start.row; - var endColumn = fromRange.isMultiLine() ? - fromRange.end.column : - toColumn + fromRange.end.column - fromRange.start.column; - - var toRange = new Range(toRow, toColumn, endRow, endColumn); - - this.insert(toRange.start, text); - - var delta = { - action: "move", - fromRange: fromRange, - toRange: toRange, - isMeta: true, - }; - this._dispatchEvent("change", { data: delta }); - - return toRange; - }; - this.applyDeltas = function(deltas) { for (var i=0; i=0; i--) { var delta = deltas[i]; - if (delta.isMeta) - continue; - var range = Range.fromPoints(delta.range.start, delta.range.end); if (delta.action == "insertLines") diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index a09cc018..91b219ec 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -602,6 +602,45 @@ var EditSession = function(text, mode) { return this.doc.replace(range, text); }; + /** + * Move a range of text from the given range to the given position. + * + * @param fromRange {Range} The range of text you want moved within the + * document. + * @param toPosition {Object} The location (row and column) where you want + * to move the text to. + * @return {Range} The new range where the text was moved to. + */ + this.moveText = function(fromRange, toPosition) { + var text = this.getTextRange(fromRange); + this.remove(fromRange); + + var toRow = toPosition.row; + var toColumn = toPosition.column; + + // Make sure to update the insert location, when text is removed in + // front of the chosen point of insertion. + if (!fromRange.isMultiLine() && fromRange.start.row == toRow && + fromRange.end.column < toColumn) + toColumn -= text.length; + + if (fromRange.isMultiLine() && fromRange.end.row < toRow) { + var lines = this.doc.$split(text); + toRow -= lines.length - 1; + } + + var endRow = toRow + fromRange.end.row - fromRange.start.row; + var endColumn = fromRange.isMultiLine() ? + fromRange.end.column : + toColumn + fromRange.end.column - fromRange.start.column; + + var toRange = new Range(toRow, toColumn, endRow, endColumn); + + this.insert(toRange.start, text); + + return toRange; + }; + this.indentRows = function(startRow, endRow, indentString) { indentString = indentString.replace(/\t/g, this.getTabString()); for (var row=startRow; row<=endRow; row++) { @@ -751,7 +790,7 @@ var EditSession = function(text, mode) { }; this.$updateWrapDataOnChange = function(e) { - if (!this.$useWrapMode || e.data.isMeta) { + if (!this.$useWrapMode) { return; } diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 3dfc6c83..974ae509 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -271,9 +271,6 @@ var Editor =function(renderer, session) { this.onDocumentChange = function(e) { var delta = e.data; - if (delta.isMeta) - return; - var range = delta.range; this.bgTokenizer.start(range.start.row); @@ -769,7 +766,7 @@ var Editor =function(renderer, session) { if (this.$readOnly) return null; - return this.session.doc.move(range, toPosition); + return this.session.moveText(range, toPosition); }; this.copyLinesUp = function() { diff --git a/lib/ace/mode/javascript.js b/lib/ace/mode/javascript.js index 95e2f93f..a7634bf6 100644 --- a/lib/ace/mode/javascript.js +++ b/lib/ace/mode/javascript.js @@ -1,5 +1,4 @@ -/* vim:ts=4:sts=4:sw=4: - * ***** BEGIN LICENSE BLOCK ***** +/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version @@ -129,9 +128,6 @@ oop.inherits(Mode, TextMode); worker.call("setValue", [doc.getValue()]); doc.on("change", function(e) { - if (e.data.isMeta) - return; - e.range = { start: e.data.range.start, end: e.data.range.end