From 936d5d8a0683a49e506d525be1b9e81b0c7e91d7 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 9 Apr 2018 12:06:12 +0200 Subject: [PATCH] Fixes #46942: Cover case when the mouse target is the view line and the line is empty and has an inline decoration --- src/vs/editor/browser/controller/mouseTarget.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/vs/editor/browser/controller/mouseTarget.ts b/src/vs/editor/browser/controller/mouseTarget.ts index 436f7a96967..942f7f67493 100644 --- a/src/vs/editor/browser/controller/mouseTarget.ts +++ b/src/vs/editor/browser/controller/mouseTarget.ts @@ -174,6 +174,14 @@ class ElementPath { ); } + public static isStrictChildOfViewLines(path: Uint8Array): boolean { + return ( + path.length > 4 + && path[0] === PartFingerprint.OverflowGuard + && path[3] === PartFingerprint.ViewLines + ); + } + public static isChildOfScrollableElement(path: Uint8Array): boolean { return ( path.length >= 2 @@ -621,6 +629,15 @@ export class MouseTargetFactory { } if (domHitTestExecuted) { + // 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)) { + const lineNumber = ctx.getLineNumberAtVerticalOffset(request.mouseVerticalOffset); + if (ctx.model.getLineLength(lineNumber) === 0) { + return request.fulfill(MouseTargetType.CONTENT_EMPTY, new Position(lineNumber, 1), void 0, EMPTY_CONTENT_IN_LINES); + } + } + // We have already executed hit test... return request.fulfill(MouseTargetType.UNKNOWN); }