mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-21 09:08:53 +01:00
[html] Pasting HTML code adds extra closing tag on first line (#228662)
This commit is contained in:
committed by
GitHub
parent
07bd3cfbf6
commit
f0cdaab75f
@@ -56,14 +56,20 @@ export function activateAutoInsertion(provider: (kind: 'autoQuote' | 'autoClose'
|
||||
}
|
||||
|
||||
const lastChange = contentChanges[contentChanges.length - 1];
|
||||
const lastCharacter = lastChange.text[lastChange.text.length - 1];
|
||||
if (isEnabled['autoQuote'] && lastChange.rangeLength === 0 && lastCharacter === '=') {
|
||||
doAutoInsert('autoQuote', document, lastChange);
|
||||
} else if (isEnabled['autoClose'] && lastChange.rangeLength === 0 && (lastCharacter === '>' || lastCharacter === '/')) {
|
||||
doAutoInsert('autoClose', document, lastChange);
|
||||
if (lastChange.rangeLength === 0 && isSingleLine(lastChange.text)) {
|
||||
const lastCharacter = lastChange.text[lastChange.text.length - 1];
|
||||
if (isEnabled['autoQuote'] && lastCharacter === '=') {
|
||||
doAutoInsert('autoQuote', document, lastChange);
|
||||
} else if (isEnabled['autoClose'] && (lastCharacter === '>' || lastCharacter === '/')) {
|
||||
doAutoInsert('autoClose', document, lastChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isSingleLine(text: string): boolean {
|
||||
return !/\n/.test(text);
|
||||
}
|
||||
|
||||
function doAutoInsert(kind: 'autoQuote' | 'autoClose', document: TextDocument, lastChange: TextDocumentContentChangeEvent) {
|
||||
const rangeStart = lastChange.range.start;
|
||||
const version = document.version;
|
||||
|
||||
Reference in New Issue
Block a user