mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-09-11 12:25:59 +03:00
parent
503788d199
commit
af6b0be578
@ -654,7 +654,7 @@ class SurroundHelper {
|
||||
surroundState.operator === 'delete'
|
||||
? ''
|
||||
: surroundState.tag
|
||||
? optNewline + '</' + surroundState.tag.tag + '>'
|
||||
? optNewline + '</' + SurroundHelper.trimAttributes(surroundState.tag.tag) + '>'
|
||||
: optNewline + replacement.right;
|
||||
|
||||
for (const { leftEdge, rightEdge, cursorIndex } of surroundState.edges) {
|
||||
@ -680,4 +680,10 @@ class SurroundHelper {
|
||||
// finish / cleanup. sql-koala was here :D
|
||||
await vimState.setCurrentMode(Mode.Normal);
|
||||
}
|
||||
|
||||
private static trimAttributes(wholeTag: string) {
|
||||
const endTagIndex = wholeTag.indexOf(' ');
|
||||
const isAnyAttributeAfterTag = endTagIndex !== -1;
|
||||
return isAnyAttributeAfterTag ? wholeTag.substring(0, endTagIndex) : wholeTag;
|
||||
}
|
||||
}
|
||||
|
@ -507,6 +507,18 @@ suite('surround plugin', () => {
|
||||
},
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "'VStt' surrounds selection and correctly trims class attribute in closing tag",
|
||||
start: ['first li|ne test'],
|
||||
keysPressed: 'VStt',
|
||||
end: ['<div class="test">', 'first line test', '|</div>'],
|
||||
stub: {
|
||||
stubClass: CommandSurroundAddSurroundingTag,
|
||||
methodName: 'readTag',
|
||||
returnValue: 'div class="test"',
|
||||
},
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "'S)' surrounds visual line selection without space",
|
||||
start: ['first', 'sec|ond', 'third'],
|
||||
|
Loading…
Reference in New Issue
Block a user