Skip to content

Commit 9341903

Browse files
authored
add supportsMarkerHover to HoverForeignElementAnchor and use for inlay hovering (microsoft#172532)
* add `supportsMarkerHover` to `HoverForeignElementAnchor` and use for inlay hovering fixed microsoft#140517 * make compiler happy
1 parent 0785b1c commit 9341903

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

src/vs/editor/contrib/hover/browser/contentHover.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ class ContentHoverComputer implements IHoverComputer<IHoverPart> {
639639
}
640640

641641
private static _getLineDecorations(editor: IActiveCodeEditor, anchor: HoverAnchor): IModelDecoration[] {
642-
if (anchor.type !== HoverAnchorType.Range) {
642+
if (anchor.type !== HoverAnchorType.Range && !anchor.supportsMarkerHover) {
643643
return [];
644644
}
645645

src/vs/editor/contrib/hover/browser/hoverTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class HoverForeignElementAnchor {
6767
public readonly range: Range,
6868
public readonly initialMousePosX: number | undefined,
6969
public readonly initialMousePosY: number | undefined,
70+
public readonly supportsMarkerHover: boolean | undefined
7071
) {
7172
}
7273
public equals(other: HoverAnchor) {

src/vs/editor/contrib/hover/browser/markerHoverParticipant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class MarkerHoverParticipant implements IEditorHoverParticipant<MarkerHov
6666
) { }
6767

6868
public computeSync(anchor: HoverAnchor, lineDecorations: IModelDecoration[]): MarkerHover[] {
69-
if (!this._editor.hasModel() || anchor.type !== HoverAnchorType.Range) {
69+
if (!this._editor.hasModel() || anchor.type !== HoverAnchorType.Range && !anchor.supportsMarkerHover) {
7070
return [];
7171
}
7272

src/vs/editor/contrib/inlayHints/browser/inlayHintsHover.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class InlayHintsHoverAnchor extends HoverForeignElementAnchor {
3232
initialMousePosX: number | undefined,
3333
initialMousePosY: number | undefined
3434
) {
35-
super(10, owner, part.item.anchor.range, initialMousePosX, initialMousePosY);
35+
super(10, owner, part.item.anchor.range, initialMousePosX, initialMousePosY, true);
3636
}
3737
}
3838

src/vs/editor/contrib/inlineCompletions/browser/ghostTextHoverParticipant.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,20 @@ export class InlineCompletionsHoverParticipant implements IEditorHoverParticipan
8686
// handle the case where the mouse is over the view zone
8787
const viewZoneData = target.detail;
8888
if (controller.shouldShowHoverAtViewZone(viewZoneData.viewZoneId)) {
89-
return new HoverForeignElementAnchor(1000, this, Range.fromPositions(this._editor.getModel()!.validatePosition(viewZoneData.positionBefore || viewZoneData.position)), mouseEvent.event.posx, mouseEvent.event.posy);
89+
return new HoverForeignElementAnchor(1000, this, Range.fromPositions(this._editor.getModel()!.validatePosition(viewZoneData.positionBefore || viewZoneData.position)), mouseEvent.event.posx, mouseEvent.event.posy, false);
9090
}
9191
}
9292
if (target.type === MouseTargetType.CONTENT_EMPTY) {
9393
// handle the case where the mouse is over the empty portion of a line following ghost text
9494
if (controller.shouldShowHoverAt(target.range)) {
95-
return new HoverForeignElementAnchor(1000, this, target.range, mouseEvent.event.posx, mouseEvent.event.posy);
95+
return new HoverForeignElementAnchor(1000, this, target.range, mouseEvent.event.posx, mouseEvent.event.posy, false);
9696
}
9797
}
9898
if (target.type === MouseTargetType.CONTENT_TEXT) {
9999
// handle the case where the mouse is directly over ghost text
100100
const mightBeForeignElement = target.detail.mightBeForeignElement;
101101
if (mightBeForeignElement && controller.shouldShowHoverAt(target.range)) {
102-
return new HoverForeignElementAnchor(1000, this, target.range, mouseEvent.event.posx, mouseEvent.event.posy);
102+
return new HoverForeignElementAnchor(1000, this, target.range, mouseEvent.event.posx, mouseEvent.event.posy, false);
103103
}
104104
}
105105
return null;

0 commit comments

Comments
 (0)