Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add support for square brackets and curly braces. #3

Merged
merged 1 commit into from

2 participants

@ncolgan

Includes tests.

@ncolgan ncolgan referenced this pull request
Closed

ci" ci{ di" di{ don't work #2

@georgebrock
Admin

Awesome, thanks @ncolgan.

@georgebrock georgebrock merged commit bbc3b60 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. @ncolgan
This page is out of date. Refresh to see the latest.
Showing with 79 additions and 0 deletions.
  1. +14 −0 js/text_objects.js
  2. +65 −0 tests/acceptance/text_objects.js
View
14 js/text_objects.js
@@ -60,6 +60,20 @@
textObjects['('] = textObjects['b'];
textObjects[')'] = textObjects['b'];
+ textObjects['['] = new Vimulator.TextObject({
+ name: "square brackets",
+ start: '[',
+ end: ']'
+ });
+ textObjects[']'] = textObjects['['];
+
+ textObjects['{'] = new Vimulator.TextObject({
+ name: "curly braces",
+ start: '{',
+ end: '}'
+ });
+ textObjects['}'] = textObjects['{'];
+
return {
'a': new C({
argument: "literal",
View
65 tests/acceptance/text_objects.js
@@ -30,4 +30,69 @@ describe("Text objects", function () {
expect(currentText()).toBe("Some text, no brackets");
});
});
+
+ describe("curly braces", function () {
+ beforeEach(function () {
+ reset("Text {with curly braces} is great");
+ });
+
+ it("can specify text within braces", function () {
+ pressKeys("3wdi}");
+ expect(currentText()).toBe("Text {} is great");
+ });
+
+ it("matches when the cursor is on the opening brace", function () {
+ pressKeys("f{di{");
+ expect(currentText()).toBe("Text {} is great");
+ });
+
+ it("matches when the cursor is on the closing brace", function () {
+ pressKeys("f}di}");
+ expect(currentText()).toBe("Text {} is great");
+ });
+
+ it("can specify text including the braces", function () {
+ pressKeys("3wda}");
+ expect(currentText()).toBe("Text is great");
+ });
+
+ it("does nothing if there are no braces", function () {
+ reset("Some text, no braces");
+ pressKeys("da}");
+ expect(currentText()).toBe("Some text, no braces");
+ });
+ });
+
+ describe("square brackets", function () {
+ beforeEach(function () {
+ reset("Text [with a square bracket] is great");
+ });
+
+ it("can specify text within brackets", function () {
+ pressKeys("3wdi]");
+ expect(currentText()).toBe("Text [] is great");
+ });
+
+ it("matches when the cursor is on the opening bracket", function () {
+ pressKeys("f[di[");
+ expect(currentText()).toBe("Text [] is great");
+ });
+
+ it("matches when the cursor is on the closing bracket", function () {
+ pressKeys("f]di]");
+ expect(currentText()).toBe("Text [] is great");
+ });
+
+ it("can specify text including the brackets", function () {
+ pressKeys("3wda]");
+ expect(currentText()).toBe("Text is great");
+ });
+
+ it("does nothing if there are no brackets", function () {
+ reset("Some text, no brackets");
+ pressKeys("da]");
+ expect(currentText()).toBe("Some text, no brackets");
+ });
+ });
+
});
Something went wrong with that request. Please try again.