Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix off by one errors on some change operations.

Still unhappy with manually nudging the cursor to append at the end of a row,
but it works for now and checking range.toEOL is cleaner than the previous
methods.
  • Loading branch information...
commit 5406ee5558c5752b6ef637d85aa4248572f13486 1 parent eac9df7
@georgebrock georgebrock authored
Showing with 15 additions and 1 deletion.
  1. +6 −1 js/normal_mode/operators.js
  2. +9 −0 js/range.js
View
7 js/normal_mode/operators.js
@@ -64,10 +64,15 @@
argument: "operation",
defaultCount: null,
callback: function (vim, count, motion) {
- var range = motion.execute(vim, count);
+ var range, toEOL;
+ range = motion.execute(vim, count);
if (range) {
+ toEOL = range.toEOL(vim);
range.replaceIn(vim, "");
vim.moveCursor(range.start.row, range.start.col);
+ if (toEOL) {
+ vim.cursor.col += 1; //FIXME
+ }
vim.setMode("insert");
return;
}
View
9 js/range.js
@@ -49,6 +49,11 @@
buffer.lines.splice(this.start.row + 1, this.end.row - this.start.row);
};
+ Vimulator.CharacterRange.prototype.toEOL = function (buffer) {
+ return this.end.col === buffer.lines[this.end.row].length - 1;
+ };
+
+
Vimulator.LineRange = function (start, end) {
assignOrdered(this, start, end);
};
@@ -72,4 +77,8 @@
var count = this.end.row - this.start.row + 1;
buffer.lines.splice(this.start.row, count, str);
};
+
+ Vimulator.LineRange.prototype.toEOL = function (buffer) {
+ return false;
+ };
}());
Please sign in to comment.
Something went wrong with that request. Please try again.