diff --git a/extensions/html-language-features/client/src/autoInsertion.ts b/extensions/html-language-features/client/src/autoInsertion.ts index e95e6a64a09db..3c70839befe4a 100644 --- a/extensions/html-language-features/client/src/autoInsertion.ts +++ b/extensions/html-language-features/client/src/autoInsertion.ts @@ -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;