Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement vim-textobj-entire #4580

Merged
merged 12 commits into from Mar 26, 2020
Merged

Implement vim-textobj-entire #4580

merged 12 commits into from Mar 26, 2020

Conversation

agrison
Copy link
Contributor

@agrison agrison commented Feb 24, 2020

What this PR does / why we need it:

This PR implements two text-objects from the vim-textobj-entire plugin

This Vim plugin adds two useful text-objects:

  • ae which represents the entire content of a buffer
  • ie which represents the entire content of a buffer without the leading and trailing spaces.

You can then use gUae to transform the whole text buffer content in uppercase, whereas normally you would have to use gggUG.

This text-object has the advantage that you can use it from anywhere your cursor is currently located, you don't have to be conscious of the cursor position.

Which issue(s) this PR fixes

None

Special notes for your reviewer:

What do you think?

@TravisBuddy
Copy link

Travis tests have failed

Hey @agrison,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

Node.js: 8

View build log

if [[ $(git diff-index HEAD -- *.js *.ts *.md) ]]; then git diff; echo "Prettier Failed. Run `gulp forceprettier` and commit changes to resolve."; exit 1; fi
diff --git a/README.md b/README.md
index 0b90fbc..0c73a82 100644
--- a/README.md
+++ b/README.md
@@ -619,8 +619,8 @@ Similar to [vim-textobj-entire](https://github.com/kana/vim-textobj-entire).
 
 Adds two useful text-objects:
 
-* `ae` which represents the entire content of a buffer
-* `ie` which represents the entire content of a buffer without the leading and trailing spaces.
+- `ae` which represents the entire content of a buffer
+- `ie` which represents the entire content of a buffer without the leading and trailing spaces.
 
 Usage examples:
 
@@ -628,7 +628,6 @@ Usage examples:
 - `yie` - will yank the buffer content except leading and trailing blank lines
 - `gUae` - transform the whole buffer to uppercase.
 
-
 ## 🎩 VSCodeVim tricks!
 
 VS Code has a lot of nifty tricks and we try to preserve some of them:
diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts
index 471770c..9c68429 100644
--- a/src/mode/modeHandler.ts
+++ b/src/mode/modeHandler.ts
@@ -938,7 +938,9 @@ export class ModeHandler implements vscode.Disposable {
             );
 
             if (!nextMatch) {
-              throw VimError.fromCode(command.direction > 0 ? ErrorCode.SearchHitBottom : ErrorCode.SearchHitTop);
+              throw VimError.fromCode(
+                command.direction > 0 ? ErrorCode.SearchHitBottom : ErrorCode.SearchHitTop
+              );
             }
 
             vimState.cursorStopPosition = nextMatch.pos;
diff --git a/test/mode/modeNormal.test.ts b/test/mode/modeNormal.test.ts
index 5f61448..9b9932d 100755
--- a/test/mode/modeNormal.test.ts
+++ b/test/mode/modeNormal.test.ts
@@ -359,7 +359,12 @@ suite('Mode Normal', () => {
 
   newTest({
     title: "Can handle 'cie' with leading space",
-    start: ['     ', '    ', '|Two roads diverged in a wood, and I', 'I took the one less traveled by'],
+    start: [
+      '     ',
+      '    ',
+      '|Two roads diverged in a wood, and I',
+      'I took the one less traveled by',
+    ],
     keysPressed: 'cie',
     end: ['     ', '    ', '|'],
     endMode: Mode.Insert,
@@ -367,17 +372,29 @@ suite('Mode Normal', () => {
 
   newTest({
     title: "Can handle 'cie' with trailing space",
-    start: ['Two roads |diverged in a wood, and I', 'I took the one less traveled by', '    ',  '   '],
+    start: [
+      'Two roads |diverged in a wood, and I',
+      'I took the one less traveled by',
+      '    ',
+      '   ',
+    ],
     keysPressed: 'cie',
-    end: ['|', '    ',  '   '],
+    end: ['|', '    ', '   '],
     endMode: Mode.Insert,
   });
 
   newTest({
     title: "Can handle 'cie' with both leading and trailing space",
-    start: ['  ', ' ', 'Two roads diverged in a |wood, and I', 'I took the one less traveled by', '    ',  '   '],
+    start: [
+      '  ',
+      ' ',
+      'Two roads diverged in a |wood, and I',
+      'I took the one less traveled by',
+      '    ',
+      '   ',
+    ],
     keysPressed: 'cie',
-    end: ['  ', ' ', '|', '    ',  '   '],
+    end: ['  ', ' ', '|', '    ', '   '],
     endMode: Mode.Insert,
   });
 
@@ -1100,7 +1117,12 @@ suite('Mode Normal', () => {
 
   newTest({
     title: "Can handle 'die' with leading space",
-    start: ['     ', '    ', '|Two roads diverged in a wood, and I', 'I took the one less traveled by'],
+    start: [
+      '     ',
+      '    ',
+      '|Two roads diverged in a wood, and I',
+      'I took the one less traveled by',
+    ],
     keysPressed: 'die',
     end: ['     ', '    ', '|'],
     endMode: Mode.Normal,
@@ -1108,17 +1130,29 @@ suite('Mode Normal', () => {
 
   newTest({
     title: "Can handle 'die' with trailing space",
-    start: ['Two roads |diverged in a wood, and I', 'I took the one less traveled by', '    ',  '   '],
+    start: [
+      'Two roads |diverged in a wood, and I',
+      'I took the one less traveled by',
+      '    ',
+      '   ',
+    ],
     keysPressed: 'die',
-    end: ['|', '    ',  '   '],
+    end: ['|', '    ', '   '],
     endMode: Mode.Normal,
   });
 
   newTest({
     title: "Can handle 'die' with both leading and trailing space",
-    start: ['  ', ' ', 'Two roads diverged in a |wood, and I', 'I took the one less traveled by', '    ',  '   '],
+    start: [
+      '  ',
+      ' ',
+      'Two roads diverged in a |wood, and I',
+      'I took the one less traveled by',
+      '    ',
+      '   ',
+    ],
     keysPressed: 'die',
-    end: ['  ', ' ', '|', '    ',  '   '],
+    end: ['  ', ' ', '|', '    ', '   '],
     endMode: Mode.Normal,
   });
 
@@ -1712,14 +1746,14 @@ suite('Mode Normal', () => {
     title: 'Can handle guae',
     start: ['|ABC', 'DEF', 'GHI'],
     keysPressed: 'guae',
-    end: ['|abc', 'def', 'ghi']
+    end: ['|abc', 'def', 'ghi'],
   });
 
   newTest({
     title: 'Can handle guie',
     start: [' ', ' ', '|ABC', 'DEF', 'GHI'],
     keysPressed: 'guie',
-    end: [' ', ' ', '|abc', 'def', 'ghi']
+    end: [' ', ' ', '|abc', 'def', 'ghi'],
   });
 
   newTest({
@@ -1733,14 +1767,14 @@ suite('Mode Normal', () => {
     title: 'Can handle gUae',
     start: ['|Abc', 'def', 'GhI'],
     keysPressed: 'gUae',
-    end: ['|ABC', 'DEF', 'GHI']
+    end: ['|ABC', 'DEF', 'GHI'],
   });
 
   newTest({
     title: 'Can handle gUie',
     start: [' ', ' ', '|abc', 'def', 'ghi'],
     keysPressed: 'gUie',
-    end: [' ', ' ', '|ABC', 'DEF', 'GHI']
+    end: [' ', ' ', '|ABC', 'DEF', 'GHI'],
   });
 
   newTest({
Prettier Failed. Run [14:44:55] Using gulpfile ~/build/VSCodeVim/Vim/gulpfile.js
[14:44:55] Starting 'forceprettier'...
[14:45:07] Finished 'forceprettier' after 12 s and commit changes to resolve.
TravisBuddy Request Identifier: 40605940-5714-11ea-a64d-4f32104b3b66

@agrison
Copy link
Contributor Author

agrison commented Mar 2, 2020

Any feedback ?

@agrison
Copy link
Contributor Author

agrison commented Mar 11, 2020

ping ?

@agrison
Copy link
Contributor Author

agrison commented Mar 24, 2020

ping...

@J-Fields J-Fields added this to the v1.14.0 milestone Mar 26, 2020
@J-Fields
Copy link
Member

Sorry I haven't gotten around to this, @agrison; I'll do a quick review now. I'm excited to get this into the next release!

README.md Outdated Show resolved Hide resolved
Copy link
Member

@J-Fields J-Fields left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, other than the few refactors I've requested. Thanks a bunch for the contribution!

README.md Outdated Show resolved Hide resolved
src/actions/textobject.ts Outdated Show resolved Hide resolved
src/actions/textobject.ts Outdated Show resolved Hide resolved
src/actions/textobject.ts Outdated Show resolved Hide resolved
test/mode/modeNormal.test.ts Show resolved Hide resolved
Copy link
Contributor Author

@agrison agrison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All done ✔️

Copy link
Contributor Author

@agrison agrison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@J-Fields : Doesn't seem to change the status "Changes requested"

Copy link
Member

@J-Fields J-Fields left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@J-Fields J-Fields merged commit eefae96 into VSCodeVim:master Mar 26, 2020
@J-Fields J-Fields removed this from the v1.15.0 milestone May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants