From 06d61cf239f259233504302f6f8fee822e0a0dbc Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 6 Sep 2013 14:39:20 +0400 Subject: [PATCH] add insert right mode for anchors and range_lists --- lib/ace/anchor.js | 9 +++++++-- lib/ace/range_list.js | 12 +++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/ace/anchor.js b/lib/ace/anchor.js index 7070312b..3a62e632 100644 --- a/lib/ace/anchor.js +++ b/lib/ace/anchor.js @@ -82,6 +82,10 @@ var Anchor = exports.Anchor = function(doc, row, column) { return this.document; }; + /** + * experimental: allows anchor to stick to the next on the left + */ + this.$insertRight = false; /** * Fires whenever the anchor position changes. * @@ -115,8 +119,9 @@ var Anchor = exports.Anchor = function(doc, row, column) { if (delta.action === "insertText") { if (start.row === row && start.column <= column) { - if (start.row === end.row) { - //if (start.column == column) + if (start.column === column && this.$insertRight) { + // do nothing + } else if (start.row === end.row) { column += end.column - start.column; } else { column -= start.column; diff --git a/lib/ace/range_list.js b/lib/ace/range_list.js index e186959b..0cbcc394 100644 --- a/lib/ace/range_list.js +++ b/lib/ace/range_list.js @@ -204,11 +204,17 @@ var RangeList = function() { break; if (r.start.row == startRow && r.start.column >= start.column ) { - - r.start.column += colDiff; - r.start.row += lineDif; + if (r.start.column == start.column && this.$insertRight) { + // do nothing + } else { + r.start.column += colDiff; + r.start.row += lineDif; + } } if (r.end.row == startRow && r.end.column >= start.column) { + if (r.end.column == start.column && this.$insertRight) { + continue; + } // special handling for the case when two ranges share an edge if (r.end.column == start.column && colDiff > 0 && i < n - 1) { if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)