diff --git a/extensions/html-language-features/client/src/htmlMain.ts b/extensions/html-language-features/client/src/htmlMain.ts index 9a4d392ff2831..e8a9a2fa22bdc 100644 --- a/extensions/html-language-features/client/src/htmlMain.ts +++ b/extensions/html-language-features/client/src/htmlMain.ts @@ -14,7 +14,7 @@ import { EMPTY_ELEMENTS } from './htmlEmptyTagsShared'; import { activateTagClosing } from './tagClosing'; import TelemetryReporter from 'vscode-extension-telemetry'; import { getCustomDataPathsInAllWorkspaces, getCustomDataPathsFromAllExtensions } from './customData'; -import { activateMatchingTagPosition as activateMatchingTagSelection } from './matchingTag'; +import { activateMirrorCursor } from './mirrorCursor'; namespace TagCloseRequest { export const type: RequestType = new RequestType('html/tag'); @@ -118,7 +118,7 @@ export function activate(context: ExtensionContext) { return client.sendRequest(MatchingTagPositionRequest.type, param); }; - disposable = activateMatchingTagSelection(matchingTagPositionRequestor, { html: true, handlebars: true }, 'html.mirrorCursorOnMatchingTag'); + disposable = activateMirrorCursor(matchingTagPositionRequestor, { html: true, handlebars: true }, 'html.mirrorCursorOnMatchingTag'); toDispose.push(disposable); disposable = client.onTelemetry(e => { diff --git a/extensions/html-language-features/client/src/matchingTag.ts b/extensions/html-language-features/client/src/mirrorCursor.ts similarity index 95% rename from extensions/html-language-features/client/src/matchingTag.ts rename to extensions/html-language-features/client/src/mirrorCursor.ts index d12726d35da5e..041c357032b68 100644 --- a/extensions/html-language-features/client/src/matchingTag.ts +++ b/extensions/html-language-features/client/src/mirrorCursor.ts @@ -15,7 +15,7 @@ import { WorkspaceEdit } from 'vscode'; -export function activateMatchingTagPosition( +export function activateMirrorCursor( matchingTagPositionProvider: (document: TextDocument, position: Position) => Thenable, supportedLanguages: { [id: string]: boolean }, configName: string @@ -173,10 +173,19 @@ function shouldDoCleanupForHtmlAttributeInput(document: TextDocument, firstPos: const primaryBeforeSecondary = document.offsetAt(firstPos) < document.offsetAt(secondPos); + /** + * Check two cases + *
+ *
+ * Before 1st cursor: ` ` + * After 1st cursor: `>` or ` ` + * Before 2nd cursor: ` ` + * After 2nd cursor: `>` + */ return ( primaryBeforeSecondary && charBeforePrimarySelection === ' ' && - charAfterPrimarySelection === '>' && + (charAfterPrimarySelection === '>' || charAfterPrimarySelection === ' ') && charBeforeSecondarySelection === ' ' && charAfterSecondarySelection === '>' );