Avoid doing a hit test if the line is empty or if the mouse is after the line width (also fixes #208262)

This commit is contained in:
Alex Dima 2024-03-26 17:09:14 +01:00
parent 27eb6dfa41
commit 4284fcd37f
No known key found for this signature in database
GPG key ID: 4FA498B1FFF19E4D

View file

@ -737,20 +737,6 @@ export class MouseTargetFactory {
return request.fulfillContentEmpty(new Position(lineCount, maxLineColumn), EMPTY_CONTENT_AFTER_LINES);
}
// Do the hit test (if not already done)
const hitTestResult = request.hitTestResult.value;
if (hitTestResult.type === HitTestResultType.Content) {
return MouseTargetFactory.createMouseTargetFromHitTestPosition(ctx, request, hitTestResult.spanNode, hitTestResult.position, hitTestResult.injectedText);
}
// We didn't hit content...
if (request.wouldBenefitFromHitTestTargetSwitch) {
// We actually hit something different... Give it one last change by trying again with this new target
request.switchToHitTestTarget();
return this._createMouseTarget(ctx, request);
}
// Check if we are hitting a view-line (can happen in the case of inline decorations on empty lines)
// See https://github.com/microsoft/vscode/issues/46942
if (ElementPath.isStrictChildOfViewLines(request.targetPath)) {
@ -770,6 +756,20 @@ export class MouseTargetFactory {
}
}
// Do the hit test (if not already done)
const hitTestResult = request.hitTestResult.value;
if (hitTestResult.type === HitTestResultType.Content) {
return MouseTargetFactory.createMouseTargetFromHitTestPosition(ctx, request, hitTestResult.spanNode, hitTestResult.position, hitTestResult.injectedText);
}
// We didn't hit content...
if (request.wouldBenefitFromHitTestTargetSwitch) {
// We actually hit something different... Give it one last change by trying again with this new target
request.switchToHitTestTarget();
return this._createMouseTarget(ctx, request);
}
// We have tried everything...
return request.fulfillUnknown();
}