diff --git a/src/services/htmlCompletion.ts b/src/services/htmlCompletion.ts index b6e8dfb..d6e899b 100644 --- a/src/services/htmlCompletion.ts +++ b/src/services/htmlCompletion.ts @@ -294,6 +294,10 @@ export class HTMLCompletion { // valueEnd points to the char after quote, which encloses the replace range if (valueEnd > valueStart && text[valueEnd - 1] === text[valueStart]) { valueContentEnd--; + } else { + // unclosed quote: clamp the end to the cursor position so that + // the replace range does not extend into subsequent HTML content + valueContentEnd = offset; } const wsBefore = getWordStart(text, offset, valueContentStart); diff --git a/src/test/completion.test.ts b/src/test/completion.test.ts index 8d4988b..fc7e2ab 100644 --- a/src/test/completion.test.ts +++ b/src/test/completion.test.ts @@ -164,6 +164,15 @@ suite('HTML Completion', () => { testCompletionFor('' }] + }); + testCompletionFor('