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

fixes #2769 #2772

Merged
merged 1 commit into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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