Permalink
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...
1 parent eac9df7 commit 5406ee5558c5752b6ef637d85aa4248572f13486 @georgebrock georgebrock committed Dec 10, 2012
Showing with 15 additions and 1 deletion.
  1. +6 −1 js/normal_mode/operators.js
  2. +9 −0 js/range.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
@@ -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;
+ };
}());

0 comments on commit 5406ee5

Please sign in to comment.