Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use new ranges for text objects.

  • Loading branch information...
commit 71258bac2a15140673249a299965d90319dc4bf8 1 parent 89aadd4
@georgebrock georgebrock authored
View
11 js/normal_mode/operators.js
@@ -49,8 +49,9 @@
return;
}
- before = range.start;
- after = range.end;
+ range.removeFrom(vim);
+ vim.moveCursor(range.start.row, range.start.col);
+ return;
}
// Some motions delete the character the cursor lands on,
@@ -109,8 +110,10 @@
return;
}
- before = range.start;
- after = range.end;
+ range.replaceIn(vim, "");
+ vim.moveCursor(range.start.row, range.start.col);
+ vim.setMode("insert");
+ return;
}
// Some motions change the character the cursor lands on,
View
4 js/text_objects.js
@@ -20,7 +20,7 @@
});
if (start && end) {
- return {start: start, end: end};
+ return new Vimulator.CharacterRange(start, end, {inclusive: true});
} else {
return null;
}
@@ -39,7 +39,7 @@
});
if (start && end) {
- return {start: start, end: end};
+ return new Vimulator.CharacterRange(start, end, {inclusive: true});
} else {
return null;
}
View
4 tests/unit/text_object.js
@@ -16,6 +16,7 @@ describe("TextObject", function () {
expect(range.start).toEqual({row: 0, col: 11});
expect(range.end).toEqual({row: 0, col: 21});
+ expect(range.inclusive).toBe(true);
});
it("works accross multiple lines", function () {
@@ -26,6 +27,7 @@ describe("TextObject", function () {
expect(range.start).toEqual({row: 0, col: 11});
expect(range.end).toEqual({row: 2, col: 12});
+ expect(range.inclusive).toBe(true);
});
it("returns null for unmatched parens", function () {
@@ -49,6 +51,7 @@ describe("TextObject", function () {
expect(range.start).toEqual({row: 0, col: 10});
expect(range.end).toEqual({row: 0, col: 22});
+ expect(range.inclusive).toBe(true);
});
it("works accross multiple lines", function () {
@@ -59,6 +62,7 @@ describe("TextObject", function () {
expect(range.start).toEqual({row: 0, col: 10});
expect(range.end).toEqual({row: 2, col: 13});
+ expect(range.inclusive).toBe(true);
});
it("returns null for unmatched parens", function () {
Please sign in to comment.
Something went wrong with that request. Please try again.