|
@@ -176,19 +176,24 @@ Formatter.prototype._processKey = function (chars, delKey) { |
|
|
this.delta = (-1) * Math.abs(this.sel.begin - this.sel.end);
|
|
|
this.val = utils.removeChars(this.val, this.sel.begin, this.sel.end);
|
|
|
}
|
|
|
-
|
|
|
- // If delKey Backspace key and a Delete key
|
|
|
+ // If delKey
|
|
|
else if (delKey) {
|
|
|
- // Key is delete. Make sure not at str end
|
|
|
- if (delKey == 46 && this.sel.begin < this.val.length) {
|
|
|
- // We will simulate a delete by moving the caret forward
|
|
|
- // by 1 and then deleting
|
|
|
- this.sel.end ++;
|
|
|
- this.sel.begin ++;
|
|
|
- this.val = utils.removeChars(this.val, this.sel.end -1, this.sel.end);
|
|
|
- this.delta = -1;
|
|
|
- // Key is backspace. Make sure not at str start
|
|
|
- } else if (this.sel.begin - 1 >= 0) {
|
|
|
+ // Delete
|
|
|
+ if (delKey && delKey == 46) {
|
|
|
+ // Adjust focus to make sure its not on a formatted char
|
|
|
+ while (this.chars[this.sel.begin]) {
|
|
|
+ this._nextPos();
|
|
|
+ }
|
|
|
+ // As long as we are not at the end
|
|
|
+ if (this.sel.begin < this.val.length) {
|
|
|
+ // We will simulate a delete by moving the caret to the next char
|
|
|
+ // and then deleting
|
|
|
+ this._nextPos();
|
|
|
+ this.val = utils.removeChars(this.val, this.sel.end -1, this.sel.end);
|
|
|
+ this.delta = -1;
|
|
|
+ }
|
|
|
+ // or Backspace and not at start
|
|
|
+ } else if (delKey && this.sel.begin - 1 >= 0) {
|
|
|
this.val = utils.removeChars(this.val, this.sel.end -1, this.sel.end);
|
|
|
this.delta = -1;
|
|
|
}
|
|
@@ -207,6 +212,15 @@ Formatter.prototype._processKey = function (chars, delKey) { |
|
|
|
|
|
//
|
|
|
// @private
|
|
|
+// Quick helper method to move the caret to the next pos
|
|
|
+//
|
|
|
+Formatter.prototype._nextPos = function () {
|
|
|
+ this.sel.end ++;
|
|
|
+ this.sel.begin ++;
|
|
|
+};
|
|
|
+
|
|
|
+//
|
|
|
+// @private
|
|
|
// Alter element value to display characters matching the provided
|
|
|
// instance pattern. Also responsible for updatin
|
|
|
//
|
|
|
0 comments on commit
482c061