Skip to content

Commit 7fada39

Browse files
committed
1 parent 29474d5 commit 7fada39

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
@@ -161,6 +161,36 @@ function isCharBeforeAndAfterPositionsRoughtlyEqual(document: TextDocument, firs
161161
const charBeforeSecondarySelection = getCharBefore(document, secondPos);
162162
const charAfterSecondarySelection = getCharAfter(document, secondPos);
163163

164+
/**
165+
* Special case for exiting
166+
* |<div>
167+
* |</div>
168+
*/
169+
if (
170+
charBeforePrimarySelection === ' ' &&
171+
charBeforeSecondarySelection === ' ' &&
172+
charAfterPrimarySelection === '<' &&
173+
charAfterSecondarySelection === '<'
174+
) {
175+
return false;
176+
}
177+
/**
178+
* Special case for exiting
179+
* | <div>
180+
* | </div>
181+
*/
182+
if (charBeforePrimarySelection === '\n' && charBeforeSecondarySelection === '\n') {
183+
return false;
184+
}
185+
/**
186+
* Special case for exiting
187+
* <div>|
188+
* </div>|
189+
*/
190+
if (charAfterPrimarySelection === '\n' && charAfterSecondarySelection === '\n') {
191+
return false;
192+
}
193+
164194
// Exit mirror mode when cursor position no longer mirror
165195
// Unless it's in the case of `<|></|>`
166196
const charBeforeBothPositionRoughlyEqual =

0 commit comments

Comments
 (0)