mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-20 08:37:45 +03:00
feat(surround): support complex tags surround
This commit is contained in:
parent
09b50ab38a
commit
dd5e59c4ca
@ -277,7 +277,12 @@ export class CommandSurroundAddToReplacement extends BaseCommand {
|
|||||||
let endReplace = replacement;
|
let endReplace = replacement;
|
||||||
|
|
||||||
if (startReplace[0] === "<") {
|
if (startReplace[0] === "<") {
|
||||||
endReplace = startReplace[0] + "/" + startReplace.slice(1);
|
let tagName = /([-\w]+)/.exec(startReplace);
|
||||||
|
if (tagName) {
|
||||||
|
endReplace = `</${tagName[1]}>`;
|
||||||
|
} else {
|
||||||
|
endReplace = "</" + startReplace.slice(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startReplace.length === 1 && startReplace in PairMatcher.pairings) {
|
if (startReplace.length === 1 && startReplace in PairMatcher.pairings) {
|
||||||
|
@ -33,6 +33,13 @@ suite("surround plugin", () => {
|
|||||||
end: ["first <123>|line</123> test"],
|
end: ["first <123>|line</123> test"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
newTest({
|
||||||
|
title: "ysiw< surrounds word with tags and attributes",
|
||||||
|
start: ["first li|ne test"],
|
||||||
|
keysPressed: 'ysiw<abc attr1 attr2="test">',
|
||||||
|
end: ['first <abc attr1 attr2="test">|line</abc> test'],
|
||||||
|
});
|
||||||
|
|
||||||
newTest({
|
newTest({
|
||||||
title: "change surround",
|
title: "change surround",
|
||||||
start: ["first 'li|ne' test"],
|
start: ["first 'li|ne' test"],
|
||||||
|
Loading…
Reference in New Issue
Block a user