From 0feee9edefc690eba6bfbc104da08af3fd58ad53 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Wed, 26 May 2021 23:40:24 +0200 Subject: [PATCH] Remove `instanceof` check --- src/vs/editor/contrib/hover/colorHoverParticipant.ts | 6 ++++++ src/vs/editor/contrib/hover/modesContentHover.ts | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/hover/colorHoverParticipant.ts b/src/vs/editor/contrib/hover/colorHoverParticipant.ts index df42c545d9e..169b1fc9557 100644 --- a/src/vs/editor/contrib/hover/colorHoverParticipant.ts +++ b/src/vs/editor/contrib/hover/colorHoverParticipant.ts @@ -20,6 +20,12 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; export class ColorHover implements IHoverPart { + /** + * Force the hover to always be rendered at this specific range, + * even in the case of multiple hover parts. + */ + public readonly forceShowAtRange: boolean = true; + constructor( public readonly owner: IEditorHoverParticipant, public readonly range: Range, diff --git a/src/vs/editor/contrib/hover/modesContentHover.ts b/src/vs/editor/contrib/hover/modesContentHover.ts index 401d2c1990e..f56293c5713 100644 --- a/src/vs/editor/contrib/hover/modesContentHover.ts +++ b/src/vs/editor/contrib/hover/modesContentHover.ts @@ -27,11 +27,16 @@ import { HoverWidget } from 'vs/base/browser/ui/hover/hoverWidget'; import { MarkerHoverParticipant } from 'vs/editor/contrib/hover/markerHoverParticipant'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { MarkdownHoverParticipant } from 'vs/editor/contrib/hover/markdownHoverParticipant'; -import { ColorHover, ColorHoverParticipant } from 'vs/editor/contrib/hover/colorHoverParticipant'; +import { ColorHoverParticipant } from 'vs/editor/contrib/hover/colorHoverParticipant'; export interface IHoverPart { readonly owner: IEditorHoverParticipant; readonly range: Range; + /** + * Force the hover to always be rendered at this specific range, + * even in the case of multiple hover parts. + */ + readonly forceShowAtRange?: boolean; equals(other: IHoverPart): boolean; } @@ -453,7 +458,7 @@ export class ModesContentHoverWidget extends Widget implements IContentWidget, I renderColumn = Math.min(renderColumn, msg.range.startColumn); highlightRange = Range.plusRange(highlightRange, msg.range); - if (msg instanceof ColorHover) { + if (msg.forceShowAtRange) { forceShowAtRange = msg.range; }