提交 fcfa0c3a 编写于 作者: A Alex Dima

Fixes #20011: Explicit check if the view cursor is hit

上级 bf3cfd9d
...@@ -475,6 +475,19 @@ export class MouseTargetFactory { ...@@ -475,6 +475,19 @@ export class MouseTargetFactory {
private static _hitTestViewCursor(ctx: HitTestContext, request: HitTestRequest): MouseTarget { private static _hitTestViewCursor(ctx: HitTestContext, request: HitTestRequest): MouseTarget {
if (request.target) {
// Check if we've hit a painted cursor
const lastViewCursorsRenderData = ctx.lastViewCursorsRenderData;
for (let i = 0, len = lastViewCursorsRenderData.length; i < len; i++) {
const d = lastViewCursorsRenderData[i];
if (request.target === d.domNode) {
return request.fulfill(MouseTargetType.CONTENT_TEXT, d.position);
}
}
}
if (request.isInContentArea) { if (request.isInContentArea) {
// Edge has a bug when hit-testing the exact position of a cursor, // Edge has a bug when hit-testing the exact position of a cursor,
// instead of returning the correct dom node, it returns the // instead of returning the correct dom node, it returns the
......
...@@ -13,6 +13,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext'; ...@@ -13,6 +13,7 @@ import { ViewContext } from 'vs/editor/common/view/viewContext';
import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext'; import { IRenderingContext, IRestrictedRenderingContext } from 'vs/editor/common/view/renderingContext';
export interface IViewCursorRenderData { export interface IViewCursorRenderData {
domNode: HTMLElement;
position: Position; position: Position;
contentTop: number; contentTop: number;
contentLeft: number; contentLeft: number;
...@@ -190,6 +191,7 @@ export class ViewCursor { ...@@ -190,6 +191,7 @@ export class ViewCursor {
this._domNode.setHeight(this._lineHeight); this._domNode.setHeight(this._lineHeight);
return { return {
domNode: this._domNode.domNode,
position: this._position, position: this._position,
contentTop: top, contentTop: top,
contentLeft: this._renderData.left, contentLeft: this._renderData.left,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册