Skip to content

Commit 3986960

Browse files
committed
1 parent ca42425 commit 3986960

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

extensions/html-language-features/client/src/mirrorCursor.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,36 @@ function isCharBeforeAndAfterPositionsRoughtlyEqual(document: TextDocument, firs
150150
const charBeforeSecondarySelection = getCharBefore(document, secondPos);
151151
const charAfterSecondarySelection = getCharAfter(document, secondPos);
152152

153+
/**
154+
* Special case for exiting
155+
* |<div>
156+
* |</div>
157+
*/
158+
if (
159+
charBeforePrimarySelection === ' ' &&
160+
charBeforeSecondarySelection === ' ' &&
161+
charAfterPrimarySelection === '<' &&
162+
charAfterSecondarySelection === '<'
163+
) {
164+
return false;
165+
}
166+
/**
167+
* Special case for exiting
168+
* | <div>
169+
* | </div>
170+
*/
171+
if (charBeforePrimarySelection === '\n' && charBeforeSecondarySelection === '\n') {
172+
return false;
173+
}
174+
/**
175+
* Special case for exiting
176+
* <div>|
177+
* </div>|
178+
*/
179+
if (charAfterPrimarySelection === '\n' && charAfterSecondarySelection === '\n') {
180+
return false;
181+
}
182+
153183
// Exit mirror mode when cursor position no longer mirror
154184
// Unless it's in the case of `<|></|>`
155185
const charBeforeBothPositionRoughlyEqual =

0 commit comments

Comments
 (0)