Skip to content

Commit 4284fcd

Browse files
committed
Avoid doing a hit test if the line is empty or if the mouse is after the line width (also fixes microsoft#208262)
1 parent 27eb6df commit 4284fcd

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/vs/editor/browser/controller/mouseTarget.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -737,20 +737,6 @@ export class MouseTargetFactory {
737737
return request.fulfillContentEmpty(new Position(lineCount, maxLineColumn), EMPTY_CONTENT_AFTER_LINES);
738738
}
739739

740-
// Do the hit test (if not already done)
741-
const hitTestResult = request.hitTestResult.value;
742-
743-
if (hitTestResult.type === HitTestResultType.Content) {
744-
return MouseTargetFactory.createMouseTargetFromHitTestPosition(ctx, request, hitTestResult.spanNode, hitTestResult.position, hitTestResult.injectedText);
745-
}
746-
747-
// We didn't hit content...
748-
if (request.wouldBenefitFromHitTestTargetSwitch) {
749-
// We actually hit something different... Give it one last change by trying again with this new target
750-
request.switchToHitTestTarget();
751-
return this._createMouseTarget(ctx, request);
752-
}
753-
754740
// Check if we are hitting a view-line (can happen in the case of inline decorations on empty lines)
755741
// See https://github.com/microsoft/vscode/issues/46942
756742
if (ElementPath.isStrictChildOfViewLines(request.targetPath)) {
@@ -770,6 +756,20 @@ export class MouseTargetFactory {
770756
}
771757
}
772758

759+
// Do the hit test (if not already done)
760+
const hitTestResult = request.hitTestResult.value;
761+
762+
if (hitTestResult.type === HitTestResultType.Content) {
763+
return MouseTargetFactory.createMouseTargetFromHitTestPosition(ctx, request, hitTestResult.spanNode, hitTestResult.position, hitTestResult.injectedText);
764+
}
765+
766+
// We didn't hit content...
767+
if (request.wouldBenefitFromHitTestTargetSwitch) {
768+
// We actually hit something different... Give it one last change by trying again with this new target
769+
request.switchToHitTestTarget();
770+
return this._createMouseTarget(ctx, request);
771+
}
772+
773773
// We have tried everything...
774774
return request.fulfillUnknown();
775775
}

0 commit comments

Comments
 (0)