Skip to content

Commit fcfa0c3

Browse files
committed
Fixes microsoft#20011: Explicit check if the view cursor is hit
1 parent bf3cfd9 commit fcfa0c3

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,19 @@ export class MouseTargetFactory {
475475

476476
private static _hitTestViewCursor(ctx: HitTestContext, request: HitTestRequest): MouseTarget {
477477

478+
if (request.target) {
479+
// Check if we've hit a painted cursor
480+
const lastViewCursorsRenderData = ctx.lastViewCursorsRenderData;
481+
482+
for (let i = 0, len = lastViewCursorsRenderData.length; i < len; i++) {
483+
const d = lastViewCursorsRenderData[i];
484+
485+
if (request.target === d.domNode) {
486+
return request.fulfill(MouseTargetType.CONTENT_TEXT, d.position);
487+
}
488+
}
489+
}
490+
478491
if (request.isInContentArea) {
479492
// Edge has a bug when hit-testing the exact position of a cursor,
480493
// instead of returning the correct dom node, it returns the

src/vs/editor/browser/viewParts/viewCursors/viewCursor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
1313
import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
1414

1515
export interface IViewCursorRenderData {
16+
domNode: HTMLElement;
1617
position: Position;
1718
contentTop: number;
1819
contentLeft: number;
@@ -190,6 +191,7 @@ export class ViewCursor {
190191
this._domNode.setHeight(this._lineHeight);
191192

192193
return {
194+
domNode: this._domNode.domNode,
193195
position: this._position,
194196
contentTop: top,
195197
contentLeft: this._renderData.left,

0 commit comments

Comments
 (0)