Skip to content

Commit

Permalink
Merge pull request #2772 from xconverge/improve-surround-aliases
Browse files Browse the repository at this point in the history
fixes #2769
  • Loading branch information
xconverge authored Jun 26, 2018
2 parents ac559f7 + d5574c0 commit 9b8f4d3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/actions/plugins/surround.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class CommandSurroundAddTarget extends BaseCommand {
['W'],
['s'],
['p'],
['b'],
['B'],
['r'],
['a'],
];
isCompleteAction = false;
runsOnceForEveryCursor() {
Expand All @@ -64,6 +68,22 @@ class CommandSurroundAddTarget extends BaseCommand {

vimState.surround.target = this.keysPressed[this.keysPressed.length - 1];

if (vimState.surround.target === 'b') {
vimState.surround.target = ')';
}

if (vimState.surround.target === 'B') {
vimState.surround.target = '}';
}

if (vimState.surround.target === 'r') {
vimState.surround.target = ']';
}

if (vimState.surround.target === 'a') {
vimState.surround.target = '>';
}

// It's possible we're already done, e.g. dst
await CommandSurroundAddToReplacement.TryToExecuteSurround(vimState, position);

Expand Down
14 changes: 14 additions & 0 deletions test/plugins/surround.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ suite('surround plugin', () => {
end: ['first (li|ne) test'],
});

newTest({
title: 'change surround with alias',
start: ["first (li|ne) test"],
keysPressed: "csb]",
end: ['first [li|ne] test'],
});

newTest({
title: 'change surround to tags',
start: ['first [li|ne] test'],
Expand All @@ -100,6 +107,13 @@ suite('surround plugin', () => {
end: ['first li|ne test'],
});

newTest({
title: 'delete surround with alias',
start: ["first {li|ne} test"],
keysPressed: "dsB",
end: ['first li|ne test'],
});

newTest({
title: 'delete surround with tags',
start: ['first <test>li|ne</test> test'],
Expand Down

0 comments on commit 9b8f4d3

Please sign in to comment.