diff --git a/extensions/html-language-features/client/src/mirrorCursor.ts b/extensions/html-language-features/client/src/mirrorCursor.ts
index 8f6f3ca6db5..43ea3169c97 100644
--- a/extensions/html-language-features/client/src/mirrorCursor.ts
+++ b/extensions/html-language-features/client/src/mirrorCursor.ts
@@ -161,6 +161,36 @@ function isCharBeforeAndAfterPositionsRoughtlyEqual(document: TextDocument, firs
const charBeforeSecondarySelection = getCharBefore(document, secondPos);
const charAfterSecondarySelection = getCharAfter(document, secondPos);
+ /**
+ * Special case for exiting
+ * |
+ * |
+ */
+ if (
+ charBeforePrimarySelection === ' ' &&
+ charBeforeSecondarySelection === ' ' &&
+ charAfterPrimarySelection === '<' &&
+ charAfterSecondarySelection === '<'
+ ) {
+ return false;
+ }
+ /**
+ * Special case for exiting
+ * |
+ * |
+ */
+ if (charBeforePrimarySelection === '\n' && charBeforeSecondarySelection === '\n') {
+ return false;
+ }
+ /**
+ * Special case for exiting
+ * |
+ *
|
+ */
+ if (charAfterPrimarySelection === '\n' && charAfterSecondarySelection === '\n') {
+ return false;
+ }
+
// Exit mirror mode when cursor position no longer mirror
// Unless it's in the case of `<|>|>`
const charBeforeBothPositionRoughlyEqual =