Merge pull request #209442 from microsoft/tyriar/204965

Introduce IHoverService.setupUpdatableHover
This commit is contained in:
Daniel Imms 2024-04-03 14:13:39 -07:00 committed by GitHub
commit feb823cc57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
119 changed files with 1195 additions and 869 deletions

View file

@ -11,7 +11,6 @@ import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { ISelectBoxOptions, ISelectBoxStyles, ISelectOptionItem, SelectBox } from 'vs/base/browser/ui/selectBox/selectBox';
import { IToggleStyles } from 'vs/base/browser/ui/toggle/toggle';
import { Action, ActionRunner, IAction, IActionChangeEvent, IActionRunner, Separator } from 'vs/base/common/actions';
@ -20,6 +19,8 @@ import * as platform from 'vs/base/common/platform';
import * as types from 'vs/base/common/types';
import 'vs/css!./actionbar';
import * as nls from 'vs/nls';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
export interface IBaseActionViewItemOptions {
draggable?: boolean;
@ -35,7 +36,7 @@ export class BaseActionViewItem extends Disposable implements IActionViewItem {
_context: unknown;
readonly _action: IAction;
private customHover?: ICustomHover;
private customHover?: IUpdatableHover;
get action() {
return this._action;
@ -232,7 +233,7 @@ export class BaseActionViewItem extends Disposable implements IActionViewItem {
} else {
if (!this.customHover && title !== '') {
const hoverDelegate = this.options.hoverDelegate ?? getDefaultHoverDelegate('element');
this.customHover = this._store.add(setupCustomHover(hoverDelegate, this.element, title));
this.customHover = this._store.add(getBaseLayerHoverDelegate().setupUpdatableHover(hoverDelegate, this.element, title));
} else if (this.customHover) {
this.customHover.update(title);
}

View file

@ -11,7 +11,6 @@ import { renderMarkdown, renderStringAsPlaintext } from 'vs/base/browser/markdow
import { Gesture, EventType as TouchEventType } from 'vs/base/browser/touch';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { Action, IAction, IActionRunner } from 'vs/base/common/actions';
import { Codicon } from 'vs/base/common/codicons';
@ -23,6 +22,8 @@ import { Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecyc
import { ThemeIcon } from 'vs/base/common/themables';
import 'vs/css!./button';
import { localize } from 'vs/nls';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
export interface IButtonOptions extends Partial<IButtonStyles> {
readonly title?: boolean | string;
@ -78,7 +79,7 @@ export class Button extends Disposable implements IButton {
protected _label: string | IMarkdownString = '';
protected _labelElement: HTMLElement | undefined;
protected _labelShortElement: HTMLElement | undefined;
private _hover: ICustomHover | undefined;
private _hover: IUpdatableHover | undefined;
private _onDidClick = this._register(new Emitter<Event>());
get onDidClick(): BaseEvent<Event> { return this._onDidClick.event; }
@ -304,7 +305,7 @@ export class Button extends Disposable implements IButton {
private setTitle(title: string) {
if (!this._hover && title !== '') {
this._hover = this._register(setupCustomHover(this.options.hoverDelegate ?? getDefaultHoverDelegate('mouse'), this._element, title));
this._hover = this._register(getBaseLayerHoverDelegate().setupUpdatableHover(this.options.hoverDelegate ?? getDefaultHoverDelegate('mouse'), this._element, title));
} else if (this._hover) {
this._hover.update(title);
}
@ -368,7 +369,7 @@ export class ButtonWithDropdown extends Disposable implements IButton {
this.separator.style.backgroundColor = options.buttonSeparator ?? '';
this.dropdownButton = this._register(new Button(this.element, { ...options, title: false, supportIcons: true }));
this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.dropdownButton.element, localize("button dropdown more actions", 'More Actions...')));
this._register(getBaseLayerHoverDelegate().setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.dropdownButton.element, localize("button dropdown more actions", 'More Actions...')));
this.dropdownButton.element.setAttribute('aria-haspopup', 'true');
this.dropdownButton.element.setAttribute('aria-expanded', 'false');
this.dropdownButton.element.classList.add('monaco-dropdown-button');

View file

@ -8,8 +8,9 @@ import { $, addDisposableListener, append, EventHelper, EventType, isMouseEvent
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { EventType as GestureEventType, Gesture } from 'vs/base/browser/touch';
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IMenuOptions } from 'vs/base/browser/ui/menu/menu';
import { ActionRunner, IAction } from 'vs/base/common/actions';
import { Emitter } from 'vs/base/common/event';
@ -36,7 +37,7 @@ class BaseDropdown extends ActionRunner {
private _onDidChangeVisibility = this._register(new Emitter<boolean>());
readonly onDidChangeVisibility = this._onDidChangeVisibility.event;
private hover: ICustomHover | undefined;
private hover: IUpdatableHover | undefined;
constructor(container: HTMLElement, options: IBaseDropdownOptions) {
super();
@ -106,7 +107,7 @@ class BaseDropdown extends ActionRunner {
set tooltip(tooltip: string) {
if (this._label) {
if (!this.hover && tooltip !== '') {
this.hover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this._label, tooltip));
this.hover = this._register(getBaseLayerHoverDelegate().setupUpdatableHover(getDefaultHoverDelegate('mouse'), this._label, tooltip));
} else if (this.hover) {
this.hover.update(tooltip);
}

View file

@ -19,8 +19,8 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import { ResolvedKeybinding } from 'vs/base/common/keybindings';
import { IDisposable } from 'vs/base/common/lifecycle';
import 'vs/css!./dropdown';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
export interface IKeybindingProvider {
(action: IAction): ResolvedKeybinding | undefined;
@ -93,7 +93,7 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem {
this.element.setAttribute('aria-haspopup', 'true');
this.element.setAttribute('aria-expanded', 'false');
if (this._action.label) {
this._register(setupCustomHover(this.options.hoverDelegate ?? getDefaultHoverDelegate('mouse'), this.element, this._action.label));
this._register(getBaseLayerHoverDelegate().setupUpdatableHover(this.options.hoverDelegate ?? getDefaultHoverDelegate('mouse'), this.element, this._action.label));
}
this.element.ariaLabel = this._action.label || '';

View file

@ -4,9 +4,10 @@
*--------------------------------------------------------------------------------------------*/
import * as dom from 'vs/base/browser/dom';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { Disposable } from 'vs/base/common/lifecycle';
import * as objects from 'vs/base/common/objects';
@ -42,7 +43,7 @@ export class HighlightedLabel extends Disposable {
private highlights: readonly IHighlight[] = [];
private supportIcons: boolean;
private didEverRender: boolean = false;
private customHover: ICustomHover | undefined;
private customHover: IUpdatableHover | undefined;
/**
* Create a new {@link HighlightedLabel}.
@ -140,7 +141,7 @@ export class HighlightedLabel extends Disposable {
} else {
if (!this.customHover && this.title !== '') {
const hoverDelegate = this.options?.hoverDelegate ?? getDefaultHoverDelegate('mouse');
this.customHover = this._register(setupCustomHover(hoverDelegate, this.domNode, this.title));
this.customHover = this._register(getBaseLayerHoverDelegate().setupUpdatableHover(hoverDelegate, this.domNode, this.title));
} else if (this.customHover) {
this.customHover.update(this.title);
}

View file

@ -0,0 +1,269 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import type { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import type { CancellationToken } from 'vs/base/common/cancellation';
import type { IMarkdownString } from 'vs/base/common/htmlContent';
import type { IDisposable } from 'vs/base/common/lifecycle';
/**
* Enables the convenient display of rich markdown-based hovers in the workbench.
*/
export interface IHoverDelegate2 {
/**
* Shows a hover, provided a hover with the same options object is not already visible.
* @param options A set of options defining the characteristics of the hover.
* @param focus Whether to focus the hover (useful for keyboard accessibility).
*
* **Example:** A simple usage with a single element target.
*
* ```typescript
* showHover({
* text: new MarkdownString('Hello world'),
* target: someElement
* });
* ```
*/
showHover(options: IHoverOptions, focus?: boolean): IHoverWidget | undefined;
/**
* Hides the hover if it was visible. This call will be ignored if the the hover is currently
* "locked" via the alt/option key.
*/
hideHover(): void;
/**
* This should only be used until we have the ability to show multiple context views
* simultaneously. #188822
*/
showAndFocusLastHover(): void;
// TODO: Change hoverDelegate arg to exclude the actual delegate and instead use the new options
setupUpdatableHover(hoverDelegate: IHoverDelegate, htmlElement: HTMLElement, content: IUpdatableHoverContentOrFactory, options?: IUpdatableHoverOptions): IUpdatableHover;
}
export interface IHoverWidget extends IDisposable {
readonly isDisposed: boolean;
}
export interface IHoverOptions {
/**
* The content to display in the primary section of the hover. The type of text determines the
* default `hideOnHover` behavior.
*/
content: IMarkdownString | string | HTMLElement;
/**
* The target for the hover. This determines the position of the hover and it will only be
* hidden when the mouse leaves both the hover and the target. A HTMLElement can be used for
* simple cases and a IHoverTarget for more complex cases where multiple elements and/or a
* dispose method is required.
*/
target: IHoverTarget | HTMLElement;
/*
* The container to pass to {@link IContextViewProvider.showContextView} which renders the hover
* in. This is particularly useful for more natural tab focusing behavior, where the hover is
* created as the next tab index after the element being hovered and/or to workaround the
* element's container hiding on `focusout`.
*/
container?: HTMLElement;
/**
* An ID to associate with the hover to be used as an equality check. Normally when calling
* {@link IHoverService.showHover} the options object itself is used to determine if the hover
* is the same one that is already showing, when this is set, the ID will be used instead.
*/
id?: number | string;
/**
* A set of actions for the hover's "status bar".
*/
actions?: IHoverAction[];
/**
* An optional array of classes to add to the hover element.
*/
additionalClasses?: string[];
/**
* An optional link handler for markdown links, if this is not provided the IOpenerService will
* be used to open the links using its default options.
*/
linkHandler?(url: string): void;
/**
* Whether to trap focus in the following ways:
* - When the hover closes, focus goes to the element that had focus before the hover opened
* - If there are elements in the hover to focus, focus stays inside of the hover when tabbing
* Note that this is overridden to true when in screen reader optimized mode.
*/
trapFocus?: boolean;
/**
* Options that defines where the hover is positioned.
*/
position?: IHoverPositionOptions;
/**
* Options that defines how long the hover is shown and when it hides.
*/
persistence?: IHoverPersistenceOptions;
/**
* Options that define how the hover looks.
*/
appearance?: IHoverAppearanceOptions;
}
export interface IHoverPositionOptions {
/**
* Position of the hover. The default is to show above the target. This option will be ignored
* if there is not enough room to layout the hover in the specified position, unless the
* forcePosition option is set.
*/
hoverPosition?: HoverPosition;
/**
* Force the hover position, reducing the size of the hover instead of adjusting the hover
* position.
*/
forcePosition?: boolean;
}
export interface IHoverPersistenceOptions {
/**
* Whether to hide the hover when the mouse leaves the `target` and enters the actual hover.
* This is false by default when text is an `IMarkdownString` and true when `text` is a
* `string`. Note that this will be ignored if any `actions` are provided as hovering is
* required to make them accessible.
*
* In general hiding on hover is desired for:
* - Regular text where selection is not important
* - Markdown that contains no links where selection is not important
*/
hideOnHover?: boolean;
/**
* Whether to hide the hover when a key is pressed.
*/
hideOnKeyDown?: boolean;
/**
* Whether to make the hover sticky, this means it will not be hidden when the mouse leaves the
* hover.
*/
sticky?: boolean;
}
export interface IHoverAppearanceOptions {
/**
* Whether to show the hover pointer, a little arrow that connects the target and the hover.
*/
showPointer?: boolean;
/**
* Whether to show a compact hover, reducing the font size and padding of the hover.
*/
compact?: boolean;
/**
* When {@link hideOnHover} is explicitly true or undefined and its auto value is detected to
* hide, show a hint at the bottom of the hover explaining how to mouse over the widget. This
* should be used in the cases where despite the hover having no interactive content, it's
* likely the user may want to interact with it somehow.
*/
showHoverHint?: boolean;
/**
* Whether to skip the fade in animation, this should be used when hovering from one hover to
* another in the same group so it looks like the hover is moving from one element to the other.
*/
skipFadeInAnimation?: boolean;
}
export interface IHoverAction {
/**
* The label to use in the hover's status bar.
*/
label: string;
/**
* The command ID of the action, this is used to resolve the keybinding to display after the
* action label.
*/
commandId: string;
/**
* An optional class of an icon that will be displayed before the label.
*/
iconClass?: string;
/**
* The callback to run the action.
* @param target The action element that was activated.
*/
run(target: HTMLElement): void;
}
/**
* A target for a hover.
*/
export interface IHoverTarget extends IDisposable {
/**
* A set of target elements used to position the hover. If multiple elements are used the hover
* will try to not overlap any target element. An example use case for this is show a hover for
* wrapped text.
*/
readonly targetElements: readonly HTMLElement[];
/**
* An optional absolute x coordinate to position the hover with, for example to position the
* hover using `MouseEvent.pageX`.
*/
x?: number;
/**
* An optional absolute y coordinate to position the hover with, for example to position the
* hover using `MouseEvent.pageY`.
*/
y?: number;
}
// #region Updatable hover
export interface IUpdatableHoverTooltipMarkdownString {
markdown: IMarkdownString | string | undefined | ((token: CancellationToken) => Promise<IMarkdownString | string | undefined>);
markdownNotSupportedFallback: string | undefined;
}
export type IUpdatableHoverContent = string | IUpdatableHoverTooltipMarkdownString | HTMLElement | undefined;
export type IUpdatableHoverContentOrFactory = IUpdatableHoverContent | (() => IUpdatableHoverContent);
export interface IUpdatableHoverOptions {
actions?: IHoverAction[];
linkHandler?(url: string): void;
}
export interface IUpdatableHover extends IDisposable {
/**
* Allows to programmatically open the hover.
*/
show(focus?: boolean): void;
/**
* Allows to programmatically hide the hover.
*/
hide(): void;
/**
* Updates the contents of the hover.
*/
update(tooltip: IUpdatableHoverContent, options?: IUpdatableHoverOptions): void;
}
// #endregion Updatable hover

View file

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { IHoverWidget, IUpdatableHoverOptions } from 'vs/base/browser/ui/hover/hover';
import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import { IHoverWidget, IUpdatableHoverOptions } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { IDisposable } from 'vs/base/common/lifecycle';

View file

@ -0,0 +1,31 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { IHoverDelegate2 } from 'vs/base/browser/ui/hover/hover';
let baseHoverDelegate: IHoverDelegate2 = {
showHover: () => undefined,
hideHover: () => undefined,
showAndFocusLastHover: () => undefined,
setupUpdatableHover: () => null!,
};
/**
* Sets the hover delegate for use **only in the `base/` layer**.
*/
export function setBaseLayerHoverDelegate(hoverDelegate: IHoverDelegate2): void {
baseHoverDelegate = hoverDelegate;
}
/**
* Gets the hover delegate for use **only in the `base/` layer**.
*
* Since the hover service depends on various platform services, this delegate essentially bypasses
* the standard dependency injection mechanism by injecting a global hover service at start up. The
* only reason this should be used is if `IHoverService` is not available.
*/
export function getBaseLayerHoverDelegate(): IHoverDelegate2 {
return baseHoverDelegate;
}

View file

@ -16,10 +16,12 @@ let hoverDelegateFactory: (placement: 'mouse' | 'element', enableInstantHover: b
const defaultHoverDelegateMouse = new Lazy<IHoverDelegate>(() => hoverDelegateFactory('mouse', false));
const defaultHoverDelegateElement = new Lazy<IHoverDelegate>(() => hoverDelegateFactory('element', false));
// TODO: Remove when getDefaultHoverDelegate is no longer used
export function setHoverDelegateFactory(hoverDelegateProvider: ((placement: 'mouse' | 'element', enableInstantHover: boolean) => IScopedHoverDelegate)): void {
hoverDelegateFactory = hoverDelegateProvider;
}
// TODO: Refine type for use in new IHoverService interface
export function getDefaultHoverDelegate(placement: 'mouse' | 'element'): IHoverDelegate {
if (placement === 'element') {
return defaultHoverDelegateElement.value;
@ -27,6 +29,7 @@ export function getDefaultHoverDelegate(placement: 'mouse' | 'element'): IHoverD
return defaultHoverDelegateMouse.value;
}
// TODO: Create equivalent in IHoverService
export function createInstantHoverDelegate(): IScopedHoverDelegate {
// Creates a hover delegate with instant hover enabled.
// This hover belongs to the consumer and requires the them to dispose it.

View file

@ -1,303 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from 'vs/base/browser/dom';
import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import { IHoverDelegate, IHoverDelegateOptions, IHoverDelegateTarget } from 'vs/base/browser/ui/hover/hoverDelegate';
import { TimeoutTimer } from 'vs/base/common/async';
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
import { IMarkdownString, isMarkdownString } from 'vs/base/common/htmlContent';
import { stripIcons } from 'vs/base/common/iconLabels';
import { DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
import { isFunction, isString } from 'vs/base/common/types';
import { localize } from 'vs/nls';
export interface ITooltipMarkdownString {
markdown: IMarkdownString | string | undefined | ((token: CancellationToken) => Promise<IMarkdownString | string | undefined>);
markdownNotSupportedFallback: string | undefined;
}
export function setupNativeHover(htmlElement: HTMLElement, tooltip: string | ITooltipMarkdownString | undefined): void {
if (isString(tooltip)) {
// Icons don't render in the native hover so we strip them out
htmlElement.title = stripIcons(tooltip);
} else if (tooltip?.markdownNotSupportedFallback) {
htmlElement.title = tooltip.markdownNotSupportedFallback;
} else {
htmlElement.removeAttribute('title');
}
}
type IHoverContent = string | ITooltipMarkdownString | HTMLElement | undefined;
type IHoverContentOrFactory = IHoverContent | (() => IHoverContent);
type IResolvedHoverContent = IMarkdownString | string | HTMLElement | undefined;
/**
* Copied from src\vs\workbench\services\hover\browser\hover.ts
* @deprecated Use IHoverService
*/
interface IHoverAction {
label: string;
commandId: string;
iconClass?: string;
run(target: HTMLElement): void;
}
export interface IUpdatableHoverOptions {
actions?: IHoverAction[];
linkHandler?(url: string): void;
}
export interface ICustomHover extends IDisposable {
/**
* Allows to programmatically open the hover.
*/
show(focus?: boolean): void;
/**
* Allows to programmatically hide the hover.
*/
hide(): void;
/**
* Updates the contents of the hover.
*/
update(tooltip: IHoverContent, options?: IUpdatableHoverOptions): void;
}
export interface IHoverWidget extends IDisposable {
readonly isDisposed: boolean;
}
class UpdatableHoverWidget implements IDisposable {
private _hoverWidget: IHoverWidget | undefined;
private _cancellationTokenSource: CancellationTokenSource | undefined;
constructor(private hoverDelegate: IHoverDelegate, private target: IHoverDelegateTarget | HTMLElement, private fadeInAnimation: boolean) {
}
async update(content: IHoverContent, focus?: boolean, options?: IUpdatableHoverOptions): Promise<void> {
if (this._cancellationTokenSource) {
// there's an computation ongoing, cancel it
this._cancellationTokenSource.dispose(true);
this._cancellationTokenSource = undefined;
}
if (this.isDisposed) {
return;
}
let resolvedContent;
if (content === undefined || isString(content) || content instanceof HTMLElement) {
resolvedContent = content;
} else if (!isFunction(content.markdown)) {
resolvedContent = content.markdown ?? content.markdownNotSupportedFallback;
} else {
// compute the content, potentially long-running
// show 'Loading' if no hover is up yet
if (!this._hoverWidget) {
this.show(localize('iconLabel.loading', "Loading..."), focus);
}
// compute the content
this._cancellationTokenSource = new CancellationTokenSource();
const token = this._cancellationTokenSource.token;
resolvedContent = await content.markdown(token);
if (resolvedContent === undefined) {
resolvedContent = content.markdownNotSupportedFallback;
}
if (this.isDisposed || token.isCancellationRequested) {
// either the widget has been closed in the meantime
// or there has been a new call to `update`
return;
}
}
this.show(resolvedContent, focus, options);
}
private show(content: IResolvedHoverContent, focus?: boolean, options?: IUpdatableHoverOptions): void {
const oldHoverWidget = this._hoverWidget;
if (this.hasContent(content)) {
const hoverOptions: IHoverDelegateOptions = {
content,
target: this.target,
appearance: {
showPointer: this.hoverDelegate.placement === 'element',
skipFadeInAnimation: !this.fadeInAnimation || !!oldHoverWidget, // do not fade in if the hover is already showing
},
position: {
hoverPosition: HoverPosition.BELOW,
},
...options
};
this._hoverWidget = this.hoverDelegate.showHover(hoverOptions, focus);
}
oldHoverWidget?.dispose();
}
private hasContent(content: IResolvedHoverContent): content is NonNullable<IResolvedHoverContent> {
if (!content) {
return false;
}
if (isMarkdownString(content)) {
return !!content.value;
}
return true;
}
get isDisposed() {
return this._hoverWidget?.isDisposed;
}
dispose(): void {
this._hoverWidget?.dispose();
this._cancellationTokenSource?.dispose(true);
this._cancellationTokenSource = undefined;
}
}
function getHoverTargetElement(element: HTMLElement, stopElement?: HTMLElement): HTMLElement {
stopElement = stopElement ?? dom.getWindow(element).document.body;
while (!element.hasAttribute('custom-hover') && element !== stopElement) {
element = element.parentElement!;
}
return element;
}
export function setupCustomHover(hoverDelegate: IHoverDelegate, htmlElement: HTMLElement, content: IHoverContentOrFactory, options?: IUpdatableHoverOptions): ICustomHover {
htmlElement.setAttribute('custom-hover', 'true');
if (htmlElement.title !== '') {
console.warn('HTML element already has a title attribute, which will conflict with the custom hover. Please remove the title attribute.');
console.trace('Stack trace:', htmlElement.title);
htmlElement.title = '';
}
let hoverPreparation: IDisposable | undefined;
let hoverWidget: UpdatableHoverWidget | undefined;
const hideHover = (disposeWidget: boolean, disposePreparation: boolean) => {
const hadHover = hoverWidget !== undefined;
if (disposeWidget) {
hoverWidget?.dispose();
hoverWidget = undefined;
}
if (disposePreparation) {
hoverPreparation?.dispose();
hoverPreparation = undefined;
}
if (hadHover) {
hoverDelegate.onDidHideHover?.();
hoverWidget = undefined;
}
};
const triggerShowHover = (delay: number, focus?: boolean, target?: IHoverDelegateTarget) => {
return new TimeoutTimer(async () => {
if (!hoverWidget || hoverWidget.isDisposed) {
hoverWidget = new UpdatableHoverWidget(hoverDelegate, target || htmlElement, delay > 0);
await hoverWidget.update(typeof content === 'function' ? content() : content, focus, options);
}
}, delay);
};
let isMouseDown = false;
const mouseDownEmitter = dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_DOWN, () => {
isMouseDown = true;
hideHover(true, true);
}, true);
const mouseUpEmitter = dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_UP, () => {
isMouseDown = false;
}, true);
const mouseLeaveEmitter = dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_LEAVE, (e: MouseEvent) => {
isMouseDown = false;
hideHover(false, (<any>e).fromElement === htmlElement);
}, true);
const onMouseOver = (e: MouseEvent) => {
if (hoverPreparation) {
return;
}
const toDispose: DisposableStore = new DisposableStore();
const target: IHoverDelegateTarget = {
targetElements: [htmlElement],
dispose: () => { }
};
if (hoverDelegate.placement === undefined || hoverDelegate.placement === 'mouse') {
// track the mouse position
const onMouseMove = (e: MouseEvent) => {
target.x = e.x + 10;
if ((e.target instanceof HTMLElement) && getHoverTargetElement(e.target, htmlElement) !== htmlElement) {
hideHover(true, true);
}
};
toDispose.add(dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_MOVE, onMouseMove, true));
}
hoverPreparation = toDispose;
if ((e.target instanceof HTMLElement) && getHoverTargetElement(e.target as HTMLElement, htmlElement) !== htmlElement) {
return; // Do not show hover when the mouse is over another hover target
}
toDispose.add(triggerShowHover(hoverDelegate.delay, false, target));
};
const mouseOverDomEmitter = dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_OVER, onMouseOver, true);
const onFocus = () => {
if (isMouseDown || hoverPreparation) {
return;
}
const target: IHoverDelegateTarget = {
targetElements: [htmlElement],
dispose: () => { }
};
const toDispose: DisposableStore = new DisposableStore();
const onBlur = () => hideHover(true, true);
toDispose.add(dom.addDisposableListener(htmlElement, dom.EventType.BLUR, onBlur, true));
toDispose.add(triggerShowHover(hoverDelegate.delay, false, target));
hoverPreparation = toDispose;
};
// Do not show hover when focusing an input or textarea
let focusDomEmitter: undefined | IDisposable;
const tagName = htmlElement.tagName.toLowerCase();
if (tagName !== 'input' && tagName !== 'textarea') {
focusDomEmitter = dom.addDisposableListener(htmlElement, dom.EventType.FOCUS, onFocus, true);
}
const hover: ICustomHover = {
show: focus => {
hideHover(false, true); // terminate a ongoing mouse over preparation
triggerShowHover(0, focus); // show hover immediately
},
hide: () => {
hideHover(true, true);
},
update: async (newContent, hoverOptions) => {
content = newContent;
await hoverWidget?.update(content, undefined, hoverOptions);
},
dispose: () => {
mouseOverDomEmitter.dispose();
mouseLeaveEmitter.dispose();
mouseDownEmitter.dispose();
mouseUpEmitter.dispose();
focusDomEmitter?.dispose();
hideHover(true, true);
}
};
return hover;
}

View file

@ -7,12 +7,15 @@ import 'vs/css!./iconlabel';
import * as dom from 'vs/base/browser/dom';
import { HighlightedLabel } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { ITooltipMarkdownString, setupCustomHover, setupNativeHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IMatch } from 'vs/base/common/filters';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { equals } from 'vs/base/common/objects';
import { Range } from 'vs/base/common/range';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import type { IUpdatableHoverTooltipMarkdownString } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
import { isString } from 'vs/base/common/types';
import { stripIcons } from 'vs/base/common/iconLabels';
export interface IIconLabelCreationOptions {
readonly supportHighlights?: boolean;
@ -22,8 +25,8 @@ export interface IIconLabelCreationOptions {
}
export interface IIconLabelValueOptions {
title?: string | ITooltipMarkdownString;
descriptionTitle?: string | ITooltipMarkdownString;
title?: string | IUpdatableHoverTooltipMarkdownString;
descriptionTitle?: string | IUpdatableHoverTooltipMarkdownString;
suffix?: string;
hideIcon?: boolean;
extraClasses?: readonly string[];
@ -175,7 +178,7 @@ export class IconLabel extends Disposable {
}
}
private setupHover(htmlElement: HTMLElement, tooltip: string | ITooltipMarkdownString | undefined): void {
private setupHover(htmlElement: HTMLElement, tooltip: string | IUpdatableHoverTooltipMarkdownString | undefined): void {
const previousCustomHover = this.customHovers.get(htmlElement);
if (previousCustomHover) {
previousCustomHover.dispose();
@ -188,9 +191,19 @@ export class IconLabel extends Disposable {
}
if (this.hoverDelegate.showNativeHover) {
function setupNativeHover(htmlElement: HTMLElement, tooltip: string | IUpdatableHoverTooltipMarkdownString | undefined): void {
if (isString(tooltip)) {
// Icons don't render in the native hover so we strip them out
htmlElement.title = stripIcons(tooltip);
} else if (tooltip?.markdownNotSupportedFallback) {
htmlElement.title = tooltip.markdownNotSupportedFallback;
} else {
htmlElement.removeAttribute('title');
}
}
setupNativeHover(htmlElement, tooltip);
} else {
const hoverDisposable = setupCustomHover(this.hoverDelegate, htmlElement, tooltip);
const hoverDisposable = getBaseLayerHoverDelegate().setupUpdatableHover(this.hoverDelegate, htmlElement, tooltip);
if (hoverDisposable) {
this.customHovers.set(htmlElement, hoverDisposable);
}

View file

@ -4,14 +4,15 @@
*--------------------------------------------------------------------------------------------*/
import { reset } from 'vs/base/browser/dom';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { IDisposable } from 'vs/base/common/lifecycle';
export class SimpleIconLabel implements IDisposable {
private hover?: ICustomHover;
private hover?: IUpdatableHover;
constructor(
private readonly _container: HTMLElement
@ -23,7 +24,7 @@ export class SimpleIconLabel implements IDisposable {
set title(title: string) {
if (!this.hover && title) {
this.hover = setupCustomHover(getDefaultHoverDelegate('mouse'), this._container, title);
this.hover = getBaseLayerHoverDelegate().setupUpdatableHover(getDefaultHoverDelegate('mouse'), this._container, title);
} else if (this.hover) {
this.hover.update(title);
}

View file

@ -11,8 +11,9 @@ import { MarkdownRenderOptions } from 'vs/base/browser/markdownRenderer';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import * as aria from 'vs/base/browser/ui/aria/aria';
import { AnchorAlignment, IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { ScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import { Widget } from 'vs/base/browser/ui/widget';
import { IAction } from 'vs/base/common/actions';
@ -113,7 +114,7 @@ export class InputBox extends Widget {
private cachedContentHeight: number | undefined;
private maxHeight: number = Number.POSITIVE_INFINITY;
private scrollableElement: ScrollableElement | undefined;
private hover: ICustomHover | undefined;
private hover: IUpdatableHover | undefined;
private _onDidChange = this._register(new Emitter<string>());
public readonly onDidChange: Event<string> = this._onDidChange.event;
@ -234,7 +235,7 @@ export class InputBox extends Widget {
public setTooltip(tooltip: string): void {
this.tooltip = tooltip;
if (!this.hover) {
this.hover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.input, tooltip));
this.hover = this._register(getBaseLayerHoverDelegate().setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.input, tooltip));
} else {
this.hover.update(tooltip);
}

View file

@ -4,8 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import * as dom from 'vs/base/browser/dom';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { UILabelProvider } from 'vs/base/common/keybindingLabels';
import { ResolvedKeybinding, ResolvedChord } from 'vs/base/common/keybindings';
import { Disposable } from 'vs/base/common/lifecycle';
@ -60,7 +61,7 @@ export class KeybindingLabel extends Disposable {
private readonly keyElements = new Set<HTMLSpanElement>();
private hover: ICustomHover;
private hover: IUpdatableHover;
private keybinding: ResolvedKeybinding | undefined;
private matches: Matches | undefined;
private didEverRender: boolean;
@ -77,7 +78,7 @@ export class KeybindingLabel extends Disposable {
this.domNode.style.color = labelForeground;
}
this.hover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.domNode, ''));
this.hover = this._register(getBaseLayerHoverDelegate().setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.domNode, ''));
this.didEverRender = false;
container.appendChild(this.domNode);

View file

@ -9,8 +9,9 @@ import { IContentActionHandler } from 'vs/base/browser/formattedTextRenderer';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { renderMarkdown } from 'vs/base/browser/markdownRenderer';
import { AnchorPosition, IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IListEvent, IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { List } from 'vs/base/browser/ui/list/listWidget';
import { ISelectBoxDelegate, ISelectBoxOptions, ISelectBoxStyles, ISelectData, ISelectOptionItem } from 'vs/base/browser/ui/selectBox/selectBox';
@ -103,7 +104,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
private selectionDetailsPane!: HTMLElement;
private _skipLayout: boolean = false;
private _cachedMaxDetailsHeight?: number;
private _hover?: ICustomHover;
private _hover?: IUpdatableHover;
private _sticky: boolean = false; // for dev purposes only
@ -152,7 +153,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
private setTitle(title: string): void {
if (!this._hover && title) {
this._hover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.selectElement, title));
this._hover = this._register(getBaseLayerHoverDelegate().setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.selectElement, title));
} else if (this._hover) {
this._hover.update(title);
}

View file

@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/
import { $, append, clearNode, createStyleSheet, getContentHeight, getContentWidth } from 'vs/base/browser/dom';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { IListOptions, IListOptionsUpdate, IListStyles, List, unthemedListStyles } from 'vs/base/browser/ui/list/listWidget';
import { ISplitViewDescriptor, IView, Orientation, SplitView } from 'vs/base/browser/ui/splitview/splitview';
@ -134,7 +134,7 @@ class ColumnHeader<TRow, TCell> extends Disposable implements IView {
this.element = $('.monaco-table-th', { 'data-col-index': index }, column.label);
if (column.tooltip) {
this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.element, column.tooltip));
this._register(getBaseLayerHoverDelegate().setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.element, column.tooltip));
}
}

View file

@ -13,9 +13,10 @@ import { Emitter, Event } from 'vs/base/common/event';
import { KeyCode } from 'vs/base/common/keyCodes';
import 'vs/css!./toggle';
import { isActiveElement, $, addDisposableListener, EventType } from 'vs/base/browser/dom';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
export interface IToggleOpts extends IToggleStyles {
readonly actionClassName?: string;
@ -112,7 +113,7 @@ export class Toggle extends Widget {
readonly domNode: HTMLElement;
private _checked: boolean;
private _hover: ICustomHover;
private _hover: IUpdatableHover;
constructor(opts: IToggleOpts) {
super();
@ -133,7 +134,7 @@ export class Toggle extends Widget {
}
this.domNode = document.createElement('div');
this._hover = this._register(setupCustomHover(opts.hoverDelegate ?? getDefaultHoverDelegate('mouse'), this.domNode, this._opts.title));
this._hover = this._register(getBaseLayerHoverDelegate().setupUpdatableHover(opts.hoverDelegate ?? getDefaultHoverDelegate('mouse'), this.domNode, this._opts.title));
this.domNode.classList.add(...classes);
if (!this._opts.notFocusable) {
this.domNode.tabIndex = 0;

View file

@ -6,7 +6,7 @@
import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { editorHoverBorder } from 'vs/platform/theme/common/colorRegistry';
import { IHoverService, IHoverOptions } from 'vs/platform/hover/browser/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { HoverWidget } from 'vs/editor/browser/services/hoverService/hoverWidget';
@ -19,8 +19,11 @@ import { ResultKind } from 'vs/platform/keybinding/common/keybindingResolver';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
import { mainWindow } from 'vs/base/browser/window';
import { IHoverWidget } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { ContextViewHandler } from 'vs/platform/contextview/browser/contextViewService';
import type { IHoverOptions, IHoverWidget, IUpdatableHover, IUpdatableHoverContentOrFactory, IUpdatableHoverOptions } from 'vs/base/browser/ui/hover/hover';
import type { IHoverDelegate, IHoverDelegateTarget } from 'vs/base/browser/ui/hover/hoverDelegate';
import { UpdatableHoverWidget } from 'vs/editor/browser/services/hoverService/updatableHoverWidget';
import { TimeoutTimer } from 'vs/base/common/async';
export class HoverService extends Disposable implements IHoverService {
declare readonly _serviceBrand: undefined;
@ -183,6 +186,137 @@ export class HoverService extends Disposable implements IHoverService {
}
}
}
// TODO: Investigate performance of this function. There seems to be a lot of content created
// and thrown away on start up
setupUpdatableHover(hoverDelegate: IHoverDelegate, htmlElement: HTMLElement, content: IUpdatableHoverContentOrFactory, options?: IUpdatableHoverOptions | undefined): IUpdatableHover {
htmlElement.setAttribute('custom-hover', 'true');
if (htmlElement.title !== '') {
console.warn('HTML element already has a title attribute, which will conflict with the custom hover. Please remove the title attribute.');
console.trace('Stack trace:', htmlElement.title);
htmlElement.title = '';
}
let hoverPreparation: IDisposable | undefined;
let hoverWidget: UpdatableHoverWidget | undefined;
const hideHover = (disposeWidget: boolean, disposePreparation: boolean) => {
const hadHover = hoverWidget !== undefined;
if (disposeWidget) {
hoverWidget?.dispose();
hoverWidget = undefined;
}
if (disposePreparation) {
hoverPreparation?.dispose();
hoverPreparation = undefined;
}
if (hadHover) {
hoverDelegate.onDidHideHover?.();
hoverWidget = undefined;
}
};
const triggerShowHover = (delay: number, focus?: boolean, target?: IHoverDelegateTarget) => {
return new TimeoutTimer(async () => {
if (!hoverWidget || hoverWidget.isDisposed) {
hoverWidget = new UpdatableHoverWidget(hoverDelegate, target || htmlElement, delay > 0);
await hoverWidget.update(typeof content === 'function' ? content() : content, focus, options);
}
}, delay);
};
let isMouseDown = false;
const mouseDownEmitter = addDisposableListener(htmlElement, EventType.MOUSE_DOWN, () => {
isMouseDown = true;
hideHover(true, true);
}, true);
const mouseUpEmitter = addDisposableListener(htmlElement, EventType.MOUSE_UP, () => {
isMouseDown = false;
}, true);
const mouseLeaveEmitter = addDisposableListener(htmlElement, EventType.MOUSE_LEAVE, (e: MouseEvent) => {
isMouseDown = false;
hideHover(false, (<any>e).fromElement === htmlElement);
}, true);
const onMouseOver = (e: MouseEvent) => {
if (hoverPreparation) {
return;
}
const toDispose: DisposableStore = new DisposableStore();
const target: IHoverDelegateTarget = {
targetElements: [htmlElement],
dispose: () => { }
};
if (hoverDelegate.placement === undefined || hoverDelegate.placement === 'mouse') {
// track the mouse position
const onMouseMove = (e: MouseEvent) => {
target.x = e.x + 10;
if ((e.target instanceof HTMLElement) && getHoverTargetElement(e.target, htmlElement) !== htmlElement) {
hideHover(true, true);
}
};
toDispose.add(addDisposableListener(htmlElement, EventType.MOUSE_MOVE, onMouseMove, true));
}
hoverPreparation = toDispose;
if ((e.target instanceof HTMLElement) && getHoverTargetElement(e.target as HTMLElement, htmlElement) !== htmlElement) {
return; // Do not show hover when the mouse is over another hover target
}
toDispose.add(triggerShowHover(hoverDelegate.delay, false, target));
};
const mouseOverDomEmitter = addDisposableListener(htmlElement, EventType.MOUSE_OVER, onMouseOver, true);
const onFocus = () => {
if (isMouseDown || hoverPreparation) {
return;
}
const target: IHoverDelegateTarget = {
targetElements: [htmlElement],
dispose: () => { }
};
const toDispose: DisposableStore = new DisposableStore();
const onBlur = () => hideHover(true, true);
toDispose.add(addDisposableListener(htmlElement, EventType.BLUR, onBlur, true));
toDispose.add(triggerShowHover(hoverDelegate.delay, false, target));
hoverPreparation = toDispose;
};
// Do not show hover when focusing an input or textarea
let focusDomEmitter: undefined | IDisposable;
const tagName = htmlElement.tagName.toLowerCase();
if (tagName !== 'input' && tagName !== 'textarea') {
focusDomEmitter = addDisposableListener(htmlElement, EventType.FOCUS, onFocus, true);
}
const hover: IUpdatableHover = {
show: focus => {
hideHover(false, true); // terminate a ongoing mouse over preparation
triggerShowHover(0, focus); // show hover immediately
},
hide: () => {
hideHover(true, true);
},
update: async (newContent, hoverOptions) => {
content = newContent;
await hoverWidget?.update(content, undefined, hoverOptions);
},
dispose: () => {
mouseOverDomEmitter.dispose();
mouseLeaveEmitter.dispose();
mouseDownEmitter.dispose();
mouseUpEmitter.dispose();
focusDomEmitter?.dispose();
hideHover(true, true);
}
};
return hover;
}
}
function getHoverOptionsIdentity(options: IHoverOptions | undefined): IHoverOptions | number | string | undefined {
@ -227,6 +361,14 @@ class HoverContextViewDelegate implements IDelegate {
}
}
function getHoverTargetElement(element: HTMLElement, stopElement?: HTMLElement): HTMLElement {
stopElement = stopElement ?? getWindow(element).document.body;
while (!element.hasAttribute('custom-hover') && element !== stopElement) {
element = element.parentElement!;
}
return element;
}
registerSingleton(IHoverService, HoverService, InstantiationType.Delayed);
registerThemingParticipant((theme, collector) => {

View file

@ -8,7 +8,6 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import { Event, Emitter } from 'vs/base/common/event';
import * as dom from 'vs/base/browser/dom';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IHoverTarget, IHoverOptions } from 'vs/platform/hover/browser/hover';
import { KeyCode } from 'vs/base/common/keyCodes';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { EDITOR_FONT_DEFAULTS, IEditorOptions } from 'vs/editor/common/config/editorOptions';
@ -23,7 +22,7 @@ import { localize } from 'vs/nls';
import { isMacintosh } from 'vs/base/common/platform';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { status } from 'vs/base/browser/ui/aria/aria';
import { IHoverWidget } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import type { IHoverOptions, IHoverTarget, IHoverWidget } from 'vs/base/browser/ui/hover/hover';
const $ = dom.$;
type TargetRect = {

View file

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import type { IHoverWidget, IUpdatableHoverContent, IUpdatableHoverOptions } from 'vs/base/browser/ui/hover/hover';
import type { IHoverDelegate, IHoverDelegateOptions, IHoverDelegateTarget } from 'vs/base/browser/ui/hover/hoverDelegate';
import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { isMarkdownString, type IMarkdownString } from 'vs/base/common/htmlContent';
import { IDisposable } from 'vs/base/common/lifecycle';
import { isFunction, isString } from 'vs/base/common/types';
import { localize } from 'vs/nls';
type IUpdatableHoverResolvedContent = IMarkdownString | string | HTMLElement | undefined;
export class UpdatableHoverWidget implements IDisposable {
private _hoverWidget: IHoverWidget | undefined;
private _cancellationTokenSource: CancellationTokenSource | undefined;
constructor(private hoverDelegate: IHoverDelegate, private target: IHoverDelegateTarget | HTMLElement, private fadeInAnimation: boolean) {
}
async update(content: IUpdatableHoverContent, focus?: boolean, options?: IUpdatableHoverOptions): Promise<void> {
if (this._cancellationTokenSource) {
// there's an computation ongoing, cancel it
this._cancellationTokenSource.dispose(true);
this._cancellationTokenSource = undefined;
}
if (this.isDisposed) {
return;
}
let resolvedContent;
if (content === undefined || isString(content) || content instanceof HTMLElement) {
resolvedContent = content;
} else if (!isFunction(content.markdown)) {
resolvedContent = content.markdown ?? content.markdownNotSupportedFallback;
} else {
// compute the content, potentially long-running
// show 'Loading' if no hover is up yet
if (!this._hoverWidget) {
this.show(localize('iconLabel.loading', "Loading..."), focus);
}
// compute the content
this._cancellationTokenSource = new CancellationTokenSource();
const token = this._cancellationTokenSource.token;
resolvedContent = await content.markdown(token);
if (resolvedContent === undefined) {
resolvedContent = content.markdownNotSupportedFallback;
}
if (this.isDisposed || token.isCancellationRequested) {
// either the widget has been closed in the meantime
// or there has been a new call to `update`
return;
}
}
this.show(resolvedContent, focus, options);
}
private show(content: IUpdatableHoverResolvedContent, focus?: boolean, options?: IUpdatableHoverOptions): void {
const oldHoverWidget = this._hoverWidget;
if (this.hasContent(content)) {
const hoverOptions: IHoverDelegateOptions = {
content,
target: this.target,
appearance: {
showPointer: this.hoverDelegate.placement === 'element',
skipFadeInAnimation: !this.fadeInAnimation || !!oldHoverWidget, // do not fade in if the hover is already showing
},
position: {
hoverPosition: HoverPosition.BELOW,
},
...options
};
this._hoverWidget = this.hoverDelegate.showHover(hoverOptions, focus);
}
oldHoverWidget?.dispose();
}
private hasContent(content: IUpdatableHoverResolvedContent): content is NonNullable<IUpdatableHoverResolvedContent> {
if (!content) {
return false;
}
if (isMarkdownString(content)) {
return !!content.value;
}
return true;
}
get isDisposed() {
return this._hoverWidget?.isDisposed;
}
dispose(): void {
this._hoverWidget?.dispose();
this._cancellationTokenSource?.dispose(true);
this._cancellationTokenSource = undefined;
}
}

View file

@ -31,6 +31,7 @@ import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { IThemeService, themeColorFromId } from 'vs/platform/theme/common/themeService';
import { Selection } from 'vs/editor/common/core/selection';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const SEARCH_STRING_MAX_LENGTH = 524288;
@ -99,6 +100,7 @@ export class CommonFindController extends Disposable implements IEditorContribut
private readonly _clipboardService: IClipboardService;
protected readonly _contextKeyService: IContextKeyService;
protected readonly _notificationService: INotificationService;
protected readonly _hoverService: IHoverService;
get editor() {
return this._editor;
@ -113,7 +115,8 @@ export class CommonFindController extends Disposable implements IEditorContribut
@IContextKeyService contextKeyService: IContextKeyService,
@IStorageService storageService: IStorageService,
@IClipboardService clipboardService: IClipboardService,
@INotificationService notificationService: INotificationService
@INotificationService notificationService: INotificationService,
@IHoverService hoverService: IHoverService
) {
super();
this._editor = editor;
@ -122,6 +125,7 @@ export class CommonFindController extends Disposable implements IEditorContribut
this._storageService = storageService;
this._clipboardService = clipboardService;
this._notificationService = notificationService;
this._hoverService = hoverService;
this._updateHistoryDelayer = new Delayer<void>(500);
this._state = this._register(new FindReplaceState());
@ -448,8 +452,9 @@ export class FindController extends CommonFindController implements IFindControl
@INotificationService notificationService: INotificationService,
@IStorageService _storageService: IStorageService,
@IClipboardService clipboardService: IClipboardService,
@IHoverService hoverService: IHoverService,
) {
super(editor, _contextKeyService, _storageService, clipboardService, notificationService);
super(editor, _contextKeyService, _storageService, clipboardService, notificationService, hoverService);
this._widget = null;
this._findOptionsWidget = null;
}
@ -503,7 +508,7 @@ export class FindController extends CommonFindController implements IFindControl
}
private _createFindWidget() {
this._widget = this._register(new FindWidget(this._editor, this, this._state, this._contextViewService, this._keybindingService, this._contextKeyService, this._themeService, this._storageService, this._notificationService));
this._widget = this._register(new FindWidget(this._editor, this, this._state, this._contextViewService, this._keybindingService, this._contextKeyService, this._themeService, this._storageService, this._notificationService, this._hoverService));
this._findOptionsWidget = this._register(new FindOptionsWidget(this._editor, this._state, this._keybindingService));
}

View file

@ -43,9 +43,9 @@ import { isHighContrast } from 'vs/platform/theme/common/theme';
import { assertIsDefined } from 'vs/base/common/types';
import { defaultInputBoxStyles, defaultToggleStyles } from 'vs/platform/theme/browser/defaultStyles';
import { Selection } from 'vs/editor/common/core/selection';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { createInstantHoverDelegate, getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const findSelectionIcon = registerIcon('find-selection', Codicon.selection, nls.localize('findSelectionIcon', 'Icon for \'Find in Selection\' in the editor find widget.'));
const findCollapsedIcon = registerIcon('find-collapsed', Codicon.chevronRight, nls.localize('findCollapsedIcon', 'Icon to indicate that the editor find widget is collapsed.'));
@ -172,6 +172,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
themeService: IThemeService,
storageService: IStorageService,
notificationService: INotificationService,
private readonly _hoverService: IHoverService,
) {
super();
this._codeEditor = codeEditor;
@ -1024,7 +1025,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
onTrigger: () => {
assertIsDefined(this._codeEditor.getAction(FIND_IDS.PreviousMatchFindAction)).run().then(undefined, onUnexpectedError);
}
}));
}, this._hoverService));
// Next button
this._nextBtn = this._register(new SimpleButton({
@ -1034,7 +1035,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
onTrigger: () => {
assertIsDefined(this._codeEditor.getAction(FIND_IDS.NextMatchFindAction)).run().then(undefined, onUnexpectedError);
}
}));
}, this._hoverService));
const findPart = document.createElement('div');
findPart.className = 'find-part';
@ -1102,7 +1103,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
}
}
}
}));
}, this._hoverService));
// Replace input
this._replaceInput = this._register(new ContextScopedReplaceInput(null, undefined, {
@ -1165,7 +1166,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
e.preventDefault();
}
}
}));
}, this._hoverService));
// Replace all button
this._replaceAllBtn = this._register(new SimpleButton({
@ -1175,7 +1176,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
onTrigger: () => {
this._controller.replaceAll();
}
}));
}, this._hoverService));
const replacePart = document.createElement('div');
replacePart.className = 'replace-part';
@ -1200,7 +1201,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
}
this._showViewZone();
}
}));
}, this._hoverService));
this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
// Widget
@ -1324,7 +1325,10 @@ export class SimpleButton extends Widget {
private readonly _opts: ISimpleButtonOpts;
private readonly _domNode: HTMLElement;
constructor(opts: ISimpleButtonOpts) {
constructor(
opts: ISimpleButtonOpts,
hoverService: IHoverService
) {
super();
this._opts = opts;
@ -1341,7 +1345,7 @@ export class SimpleButton extends Widget {
this._domNode.className = className;
this._domNode.setAttribute('role', 'button');
this._domNode.setAttribute('aria-label', this._opts.label);
this._register(setupCustomHover(opts.hoverDelegate ?? getDefaultHoverDelegate('element'), this._domNode, this._opts.label));
this._register(hoverService.setupUpdatableHover(opts.hoverDelegate ?? getDefaultHoverDelegate('element'), this._domNode, this._opts.label));
this.onclick(this._domNode, (e) => {
this._opts.onTrigger();

View file

@ -18,6 +18,7 @@ import { CONTEXT_FIND_INPUT_FOCUSED } from 'vs/editor/contrib/find/browser/findM
import { withAsyncTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { INotificationService } from 'vs/platform/notification/common/notification';
@ -35,9 +36,10 @@ class TestFindController extends CommonFindController {
@IContextKeyService contextKeyService: IContextKeyService,
@IStorageService storageService: IStorageService,
@IClipboardService clipboardService: IClipboardService,
@INotificationService notificationService: INotificationService
@INotificationService notificationService: INotificationService,
@IHoverService hoverService: IHoverService
) {
super(editor, contextKeyService, storageService, clipboardService, notificationService);
super(editor, contextKeyService, storageService, clipboardService, notificationService, hoverService);
this._findInputFocused = CONTEXT_FIND_INPUT_FOCUSED.bindTo(contextKeyService);
this._updateHistoryDelayer = new Delayer<void>(50);
this.hasFocus = false;

View file

@ -40,7 +40,8 @@ import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditor/diffEditor
import { IAccessibilitySignalService } from 'vs/platform/accessibilitySignal/browser/accessibilitySignalService';
import { mainWindow } from 'vs/base/browser/window';
import { setHoverDelegateFactory } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { WorkbenchHoverDelegate } from 'vs/platform/hover/browser/hover';
import { IHoverService, WorkbenchHoverDelegate } from 'vs/platform/hover/browser/hover';
import { setBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
/**
* Description of an action contribution
@ -272,6 +273,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
@ICodeEditorService codeEditorService: ICodeEditorService,
@ICommandService commandService: ICommandService,
@IContextKeyService contextKeyService: IContextKeyService,
@IHoverService hoverService: IHoverService,
@IKeybindingService keybindingService: IKeybindingService,
@IThemeService themeService: IThemeService,
@INotificationService notificationService: INotificationService,
@ -293,6 +295,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
createAriaDomNode(options.ariaContainerElement);
setHoverDelegateFactory((placement, enableInstantHover) => instantiationService.createInstance(WorkbenchHoverDelegate, placement, enableInstantHover, {}));
setBaseLayerHoverDelegate(hoverService);
}
public addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null {
@ -415,6 +418,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
@ICodeEditorService codeEditorService: ICodeEditorService,
@ICommandService commandService: ICommandService,
@IContextKeyService contextKeyService: IContextKeyService,
@IHoverService hoverService: IHoverService,
@IKeybindingService keybindingService: IKeybindingService,
@IStandaloneThemeService themeService: IStandaloneThemeService,
@INotificationService notificationService: INotificationService,
@ -436,7 +440,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
}
const _model: ITextModel | null | undefined = options.model;
delete options.model;
super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, themeService, notificationService, accessibilityService, languageConfigurationService, languageFeaturesService);
super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, hoverService, keybindingService, themeService, notificationService, accessibilityService, languageConfigurationService, languageFeaturesService);
this._configurationService = configurationService;
this._standaloneThemeService = themeService;

View file

@ -5,7 +5,6 @@
import { ButtonBar, IButton } from 'vs/base/browser/ui/button/button';
import { createInstantHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { ActionRunner, IAction, IActionRunner, SubmenuAction, WorkbenchActionExecutedClassification, WorkbenchActionExecutedEvent } from 'vs/base/common/actions';
import { Emitter, Event } from 'vs/base/common/event';
import { DisposableStore } from 'vs/base/common/lifecycle';
@ -14,6 +13,7 @@ import { localize } from 'vs/nls';
import { MenuId, IMenuService, MenuItemAction } from 'vs/platform/actions/common/actions';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@ -44,6 +44,7 @@ export class WorkbenchButtonBar extends ButtonBar {
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
@IKeybindingService private readonly _keybindingService: IKeybindingService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService private readonly _hoverService: IHoverService,
) {
super(container);
@ -121,7 +122,7 @@ export class WorkbenchButtonBar extends ButtonBar {
} else {
tooltip = action.label;
}
this._updateStore.add(setupCustomHover(hoverDelegate, btn.element, tooltip));
this._updateStore.add(this._hoverService.setupUpdatableHover(hoverDelegate, btn.element, tooltip));
this._updateStore.add(btn.onDidClick(async () => {
this._actionRunner.run(action);
}));
@ -141,8 +142,9 @@ export class MenuWorkbenchButtonBar extends WorkbenchButtonBar {
@IContextMenuService contextMenuService: IContextMenuService,
@IKeybindingService keybindingService: IKeybindingService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
) {
super(container, options, contextMenuService, keybindingService, telemetryService);
super(container, options, contextMenuService, keybindingService, telemetryService, hoverService);
const menu = menuService.createMenu(menuId, contextKeyService);
this._store.add(menu);

View file

@ -4,234 +4,17 @@
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
import { IMarkdownString } from 'vs/base/common/htmlContent';
import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { IHoverDelegate, IHoverDelegateOptions } from 'vs/base/browser/ui/hover/hoverDelegate';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { addStandardDisposableListener } from 'vs/base/browser/dom';
import { KeyCode } from 'vs/base/common/keyCodes';
import { IHoverWidget } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import type { IHoverDelegate2, IHoverOptions, IHoverWidget } from 'vs/base/browser/ui/hover/hover';
export const IHoverService = createDecorator<IHoverService>('hoverService');
/**
* Enables the convenient display of rich markdown-based hovers in the workbench.
*/
export interface IHoverService {
export interface IHoverService extends IHoverDelegate2 {
readonly _serviceBrand: undefined;
/**
* Shows a hover, provided a hover with the same options object is not already visible.
* @param options A set of options defining the characteristics of the hover.
* @param focus Whether to focus the hover (useful for keyboard accessibility).
*
* **Example:** A simple usage with a single element target.
*
* ```typescript
* showHover({
* text: new MarkdownString('Hello world'),
* target: someElement
* });
* ```
*/
showHover(options: IHoverOptions, focus?: boolean): IHoverWidget | undefined;
/**
* Hides the hover if it was visible. This call will be ignored if the the hover is currently
* "locked" via the alt/option key.
*/
hideHover(): void;
/**
* This should only be used until we have the ability to show multiple context views
* simultaneously. #188822
*/
showAndFocusLastHover(): void;
}
export interface IHoverOptions {
/**
* The content to display in the primary section of the hover. The type of text determines the
* default `hideOnHover` behavior.
*/
content: IMarkdownString | string | HTMLElement;
/**
* The target for the hover. This determines the position of the hover and it will only be
* hidden when the mouse leaves both the hover and the target. A HTMLElement can be used for
* simple cases and a IHoverTarget for more complex cases where multiple elements and/or a
* dispose method is required.
*/
target: IHoverTarget | HTMLElement;
/*
* The container to pass to {@link IContextViewProvider.showContextView} which renders the hover
* in. This is particularly useful for more natural tab focusing behavior, where the hover is
* created as the next tab index after the element being hovered and/or to workaround the
* element's container hiding on `focusout`.
*/
container?: HTMLElement;
/**
* An ID to associate with the hover to be used as an equality check. Normally when calling
* {@link IHoverService.showHover} the options object itself is used to determine if the hover
* is the same one that is already showing, when this is set, the ID will be used instead.
*/
id?: number | string;
/**
* A set of actions for the hover's "status bar".
*/
actions?: IHoverAction[];
/**
* An optional array of classes to add to the hover element.
*/
additionalClasses?: string[];
/**
* An optional link handler for markdown links, if this is not provided the IOpenerService will
* be used to open the links using its default options.
*/
linkHandler?(url: string): void;
/**
* Whether to trap focus in the following ways:
* - When the hover closes, focus goes to the element that had focus before the hover opened
* - If there are elements in the hover to focus, focus stays inside of the hover when tabbing
* Note that this is overridden to true when in screen reader optimized mode.
*/
trapFocus?: boolean;
/**
* Options that defines where the hover is positioned.
*/
position?: IHoverPositionOptions;
/**
* Options that defines how long the hover is shown and when it hides.
*/
persistence?: IHoverPersistenceOptions;
/**
* Options that define how the hover looks.
*/
appearance?: IHoverAppearanceOptions;
}
export interface IHoverPositionOptions {
/**
* Position of the hover. The default is to show above the target. This option will be ignored
* if there is not enough room to layout the hover in the specified position, unless the
* forcePosition option is set.
*/
hoverPosition?: HoverPosition;
/**
* Force the hover position, reducing the size of the hover instead of adjusting the hover
* position.
*/
forcePosition?: boolean;
}
export interface IHoverPersistenceOptions {
/**
* Whether to hide the hover when the mouse leaves the `target` and enters the actual hover.
* This is false by default when text is an `IMarkdownString` and true when `text` is a
* `string`. Note that this will be ignored if any `actions` are provided as hovering is
* required to make them accessible.
*
* In general hiding on hover is desired for:
* - Regular text where selection is not important
* - Markdown that contains no links where selection is not important
*/
hideOnHover?: boolean;
/**
* Whether to hide the hover when a key is pressed.
*/
hideOnKeyDown?: boolean;
/**
* Whether to make the hover sticky, this means it will not be hidden when the mouse leaves the
* hover.
*/
sticky?: boolean;
}
export interface IHoverAppearanceOptions {
/**
* Whether to show the hover pointer, a little arrow that connects the target and the hover.
*/
showPointer?: boolean;
/**
* Whether to show a compact hover, reducing the font size and padding of the hover.
*/
compact?: boolean;
/**
* When {@link hideOnHover} is explicitly true or undefined and its auto value is detected to
* hide, show a hint at the bottom of the hover explaining how to mouse over the widget. This
* should be used in the cases where despite the hover having no interactive content, it's
* likely the user may want to interact with it somehow.
*/
showHoverHint?: boolean;
/**
* Whether to skip the fade in animation, this should be used when hovering from one hover to
* another in the same group so it looks like the hover is moving from one element to the other.
*/
skipFadeInAnimation?: boolean;
}
export interface IHoverAction {
/**
* The label to use in the hover's status bar.
*/
label: string;
/**
* The command ID of the action, this is used to resolve the keybinding to display after the
* action label.
*/
commandId: string;
/**
* An optional class of an icon that will be displayed before the label.
*/
iconClass?: string;
/**
* The callback to run the action.
* @param target The action element that was activated.
*/
run(target: HTMLElement): void;
}
/**
* A target for a hover.
*/
export interface IHoverTarget extends IDisposable {
/**
* A set of target elements used to position the hover. If multiple elements are used the hover
* will try to not overlap any target element. An example use case for this is show a hover for
* wrapped text.
*/
readonly targetElements: readonly HTMLElement[];
/**
* An optional absolute x coordinate to position the hover with, for example to position the
* hover using `MouseEvent.pageX`.
*/
x?: number;
/**
* An optional absolute y coordinate to position the hover with, for example to position the
* hover using `MouseEvent.pageY`.
*/
y?: number;
}
export class WorkbenchHoverDelegate extends Disposable implements IHoverDelegate {

View file

@ -0,0 +1,15 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Disposable } from 'vs/base/common/lifecycle';
import type { IHoverService } from 'vs/platform/hover/browser/hover';
export const NullHoverService: IHoverService = {
_serviceBrand: undefined,
hideHover: () => undefined,
showHover: () => undefined,
setupUpdatableHover: () => Disposable.None as any,
showAndFocusLastHover: () => undefined,
};

View file

@ -12,9 +12,10 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import { Disposable } from 'vs/base/common/lifecycle';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import 'vs/css!./link';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export interface ILinkDescriptor {
readonly label: string | HTMLElement;
@ -32,7 +33,7 @@ export interface ILinkOptions {
export class Link extends Disposable {
private el: HTMLAnchorElement;
private hover?: ICustomHover;
private hover?: IUpdatableHover;
private hoverDelegate: IHoverDelegate;
private _enabled: boolean = true;
@ -84,6 +85,7 @@ export class Link extends Disposable {
container: HTMLElement,
private _link: ILinkDescriptor,
options: ILinkOptions = {},
@IHoverService private readonly _hoverService: IHoverService,
@IOpenerService openerService: IOpenerService
) {
super();
@ -129,7 +131,7 @@ export class Link extends Disposable {
if (this.hoverDelegate.showNativeHover) {
this.el.title = title ?? '';
} else if (!this.hover && title) {
this.hover = this._register(setupCustomHover(this.hoverDelegate, this.el, title));
this.hover = this._register(this._hoverService.setupUpdatableHover(this.hoverDelegate, this.el, title));
} else if (this.hover) {
this.hover.update(title);
}

View file

@ -29,8 +29,9 @@ import { IInputBox, IKeyMods, IQuickInput, IQuickInputButton, IQuickInputHideEve
import { QuickInputBox } from './quickInputBox';
import { quickInputButtonToAction, renderQuickInputDescription } from './quickInputUtils';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IHoverOptions, IHoverService, WorkbenchHoverDelegate } from 'vs/platform/hover/browser/hover';
import { IHoverService, WorkbenchHoverDelegate } from 'vs/platform/hover/browser/hover';
import { QuickInputListFocus, QuickInputTree } from 'vs/platform/quickinput/browser/quickInputTree';
import type { IHoverOptions } from 'vs/base/browser/ui/hover/hover';
export interface IQuickInputOptions {
idPrefix: string;

View file

@ -27,7 +27,6 @@ import { KeybindingLabel } from 'vs/base/browser/ui/keybindingLabel/keybindingLa
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { isDark } from 'vs/platform/theme/common/theme';
import { URI } from 'vs/base/common/uri';
import { IHoverWidget, ITooltipMarkdownString } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { quickInputButtonToAction } from 'vs/platform/quickinput/browser/quickInputUtils';
import { Lazy } from 'vs/base/common/lazy';
import { IParsedLabelWithIcons, getCodiconAriaLabel, matchesFuzzyIconAware, parseLabelWithIcons } from 'vs/base/common/iconLabels';
@ -37,6 +36,7 @@ import { ltrim } from 'vs/base/common/strings';
import { RenderIndentGuides } from 'vs/base/browser/ui/tree/abstractTree';
import { ThrottledDelayer } from 'vs/base/common/async';
import { isCancellationError } from 'vs/base/common/errors';
import type { IHoverWidget, IUpdatableHoverTooltipMarkdownString } from 'vs/base/browser/ui/hover/hover';
const $ = dom.$;
@ -444,7 +444,7 @@ class QuickPickItemElementRenderer extends BaseQuickInputListRenderer<QuickPickI
}
// Label
let descriptionTitle: ITooltipMarkdownString | undefined;
let descriptionTitle: IUpdatableHoverTooltipMarkdownString | undefined;
// if we have a tooltip, that will be the hover,
// with the saneDescription as fallback if it
// is defined
@ -475,7 +475,7 @@ class QuickPickItemElementRenderer extends BaseQuickInputListRenderer<QuickPickI
// Detail
if (element.saneDetail) {
let title: ITooltipMarkdownString | undefined;
let title: IUpdatableHoverTooltipMarkdownString | undefined;
// If we have a tooltip, we want that to be shown and not any other hover
if (!element.saneTooltip) {
title = {
@ -576,7 +576,7 @@ class QuickPickSeparatorElementRenderer extends BaseQuickInputListRenderer<Quick
data.icon.className = '';
// Label
let descriptionTitle: ITooltipMarkdownString | undefined;
let descriptionTitle: IUpdatableHoverTooltipMarkdownString | undefined;
// if we have a tooltip, that will be the hover,
// with the saneDescription as fallback if it
// is defined
@ -601,7 +601,7 @@ class QuickPickSeparatorElementRenderer extends BaseQuickInputListRenderer<Quick
// Detail
if (element.saneDetail) {
let title: ITooltipMarkdownString | undefined;
let title: IUpdatableHoverTooltipMarkdownString | undefined;
// If we have a tooltip, we want that to be shown and not any other hover
if (!element.saneTooltip) {
title = {

View file

@ -35,6 +35,7 @@ import { $ } from 'vs/base/browser/dom';
import { HiddenItemStrategy, WorkbenchToolBar } from 'vs/platform/actions/browser/toolbar';
import { ActionViewItem, IActionViewItemOptions } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { CompositeMenuActions } from 'vs/workbench/browser/actions';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class AuxiliaryBarPart extends AbstractPaneCompositePart {
@ -78,6 +79,7 @@ export class AuxiliaryBarPart extends AbstractPaneCompositePart {
@IContextMenuService contextMenuService: IContextMenuService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@IKeybindingService keybindingService: IKeybindingService,
@IHoverService hoverService: IHoverService,
@IInstantiationService instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@ -104,6 +106,7 @@ export class AuxiliaryBarPart extends AbstractPaneCompositePart {
contextMenuService,
layoutService,
keybindingService,
hoverService,
instantiationService,
themeService,
viewDescriptorService,

View file

@ -26,7 +26,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import { URI } from 'vs/base/common/uri';
import { badgeBackground, badgeForeground, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { IHoverWidget } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import type { IHoverWidget } from 'vs/base/browser/ui/hover/hover';
export interface ICompositeBar {

View file

@ -35,7 +35,7 @@ import { IBoundarySashes } from 'vs/base/browser/ui/sash/sash';
import { IBaseActionViewItemOptions } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { createInstantHoverDelegate, getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import type { IHoverService } from 'vs/platform/hover/browser/hover';
export interface ICompositeTitleLabel {
@ -83,6 +83,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
protected readonly contextMenuService: IContextMenuService,
layoutService: IWorkbenchLayoutService,
protected readonly keybindingService: IKeybindingService,
private readonly hoverService: IHoverService,
protected readonly instantiationService: IInstantiationService,
themeService: IThemeService,
protected readonly registry: CompositeRegistry<T>,
@ -420,7 +421,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
const titleContainer = append(parent, $('.title-label'));
const titleLabel = append(titleContainer, $('h2'));
this.titleLabelElement = titleLabel;
const hover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), titleLabel, ''));
const hover = this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), titleLabel, ''));
const $this = this;
return {

View file

@ -29,8 +29,9 @@ import { Event } from 'vs/base/common/event';
import { defaultButtonStyles, defaultProgressBarStyles } from 'vs/platform/theme/browser/defaultStyles';
import { KeyCode } from 'vs/base/common/keyCodes';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class NotificationsListDelegate implements IListVirtualDelegate<INotificationViewItem> {
@ -339,6 +340,7 @@ export class NotificationTemplateRenderer extends Disposable {
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IKeybindingService private readonly keybindingService: IKeybindingService,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IHoverService private readonly hoverService: IHoverService,
) {
super();
@ -377,14 +379,14 @@ export class NotificationTemplateRenderer extends Disposable {
this.renderSeverity(notification);
// Message
const messageCustomHover = this.inputDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), this.template.message, ''));
const messageCustomHover = this.inputDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.template.message, ''));
const messageOverflows = this.renderMessage(notification, messageCustomHover);
// Secondary Actions
this.renderSecondaryActions(notification, messageOverflows);
// Source
const sourceCustomHover = this.inputDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), this.template.source, ''));
const sourceCustomHover = this.inputDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.template.source, ''));
this.renderSource(notification, sourceCustomHover);
// Buttons
@ -422,7 +424,7 @@ export class NotificationTemplateRenderer extends Disposable {
this.template.icon.classList.add(...ThemeIcon.asClassNameArray(this.toSeverityIcon(notification.severity)));
}
private renderMessage(notification: INotificationViewItem, customHover: ICustomHover): boolean {
private renderMessage(notification: INotificationViewItem, customHover: IUpdatableHover): boolean {
clearNode(this.template.message);
this.template.message.appendChild(NotificationMessageRenderer.render(notification.message, {
callback: link => this.openerService.open(URI.parse(link), { allowCommands: true }),
@ -472,7 +474,7 @@ export class NotificationTemplateRenderer extends Disposable {
actions.forEach(action => this.template.toolbar.push(action, { icon: true, label: false, keybinding: this.getKeybindingLabel(action) }));
}
private renderSource(notification: INotificationViewItem, sourceCustomHover: ICustomHover): void {
private renderSource(notification: INotificationViewItem, sourceCustomHover: IUpdatableHover): void {
if (notification.expanded && notification.source) {
this.template.source.textContent = localize('notificationSource', "Source: {0}", notification.source);
sourceCustomHover.update(notification.source);

View file

@ -39,6 +39,7 @@ import { IAction, SubmenuAction } from 'vs/base/common/actions';
import { Composite } from 'vs/workbench/browser/composite';
import { ViewsSubMenu } from 'vs/workbench/browser/parts/views/viewPaneContainer';
import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export enum CompositeBarPosition {
TOP,
@ -141,6 +142,7 @@ export abstract class AbstractPaneCompositePart extends CompositePart<PaneCompos
@IContextMenuService contextMenuService: IContextMenuService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@IKeybindingService keybindingService: IKeybindingService,
@IHoverService hoverService: IHoverService,
@IInstantiationService instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@IViewDescriptorService private readonly viewDescriptorService: IViewDescriptorService,
@ -166,6 +168,7 @@ export abstract class AbstractPaneCompositePart extends CompositePart<PaneCompos
contextMenuService,
layoutService,
keybindingService,
hoverService,
instantiationService,
themeService,
Registry.as<PaneCompositeRegistry>(registryId),

View file

@ -29,6 +29,7 @@ import { AbstractPaneCompositePart, CompositeBarPosition } from 'vs/workbench/br
import { ICommandService } from 'vs/platform/commands/common/commands';
import { createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
import { IPaneCompositeBarOptions } from 'vs/workbench/browser/parts/paneCompositeBar';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class PanelPart extends AbstractPaneCompositePart {
@ -70,6 +71,7 @@ export class PanelPart extends AbstractPaneCompositePart {
@IContextMenuService contextMenuService: IContextMenuService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@IKeybindingService keybindingService: IKeybindingService,
@IHoverService hoverService: IHoverService,
@IInstantiationService instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@ -92,6 +94,7 @@ export class PanelPart extends AbstractPaneCompositePart {
contextMenuService,
layoutService,
keybindingService,
hoverService,
instantiationService,
themeService,
viewDescriptorService,

View file

@ -31,6 +31,7 @@ import { Action2, IMenuService, registerAction2 } from 'vs/platform/actions/comm
import { Separator } from 'vs/base/common/actions';
import { ToggleActivityBarVisibilityActionId } from 'vs/workbench/browser/actions/layoutActions';
import { localize2 } from 'vs/nls';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class SidebarPart extends AbstractPaneCompositePart {
@ -70,6 +71,7 @@ export class SidebarPart extends AbstractPaneCompositePart {
@IContextMenuService contextMenuService: IContextMenuService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@IKeybindingService keybindingService: IKeybindingService,
@IHoverService hoverService: IHoverService,
@IInstantiationService instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@IViewDescriptorService viewDescriptorService: IViewDescriptorService,
@ -92,6 +94,7 @@ export class SidebarPart extends AbstractPaneCompositePart {
contextMenuService,
layoutService,
keybindingService,
hoverService,
instantiationService,
themeService,
viewDescriptorService,

View file

@ -21,10 +21,11 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
import { renderIcon, renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { spinningLoading, syncing } from 'vs/platform/theme/common/iconRegistry';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { isMarkdownString, markdownStringEqual } from 'vs/base/common/htmlContent';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { Gesture, EventType as TouchEventType } from 'vs/base/browser/touch';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class StatusbarEntryItem extends Disposable {
@ -41,7 +42,7 @@ export class StatusbarEntryItem extends Disposable {
private readonly focusListener = this._register(new MutableDisposable());
private readonly focusOutListener = this._register(new MutableDisposable());
private hover: ICustomHover | undefined = undefined;
private hover: IUpdatableHover | undefined = undefined;
readonly labelContainer: HTMLElement;
readonly beakContainer: HTMLElement;
@ -59,6 +60,7 @@ export class StatusbarEntryItem extends Disposable {
entry: IStatusbarEntry,
private readonly hoverDelegate: IHoverDelegate,
@ICommandService private readonly commandService: ICommandService,
@IHoverService private readonly hoverService: IHoverService,
@INotificationService private readonly notificationService: INotificationService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
@IThemeService private readonly themeService: IThemeService
@ -120,7 +122,7 @@ export class StatusbarEntryItem extends Disposable {
if (this.hover) {
this.hover.update(hoverContents);
} else {
this.hover = this._register(setupCustomHover(this.hoverDelegate, this.container, hoverContents));
this.hover = this._register(this.hoverService.setupUpdatableHover(this.hoverDelegate, this.container, hoverContents));
}
if (entry.command !== ShowTooltipCommand /* prevents flicker on click */) {
this.focusListener.value = addDisposableListener(this.labelContainer, EventType.FOCUS, e => {

View file

@ -7,7 +7,6 @@ import { isActiveDocument, reset } from 'vs/base/browser/dom';
import { BaseActionViewItem, IBaseActionViewItemOptions } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { renderIcon } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { IAction, SubmenuAction } from 'vs/base/common/actions';
import { Codicon } from 'vs/base/common/codicons';
@ -22,6 +21,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { WindowTitle } from 'vs/workbench/browser/parts/titlebar/windowTitle';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class CommandCenterControl {
@ -82,6 +82,7 @@ class CommandCenterCenterViewItem extends BaseActionViewItem {
private readonly _submenu: SubmenuItemAction,
private readonly _windowTitle: WindowTitle,
options: IBaseActionViewItemOptions,
@IHoverService private readonly _hoverService: IHoverService,
@IKeybindingService private _keybindingService: IKeybindingService,
@IInstantiationService private _instaService: IInstantiationService,
@IEditorGroupsService private _editorGroupService: IEditorGroupsService,
@ -95,7 +96,7 @@ class CommandCenterCenterViewItem extends BaseActionViewItem {
container.classList.add('command-center-center');
container.classList.toggle('multiple', (this._submenu.actions.length > 1));
const hover = this._store.add(setupCustomHover(this._hoverDelegate, container, this.getTooltip()));
const hover = this._store.add(this._hoverService.setupUpdatableHover(this._hoverDelegate, container, this.getTooltip()));
// update label & tooltip when window title changes
this._store.add(this._windowTitle.onDidChange(() => {
@ -156,7 +157,7 @@ class CommandCenterCenterViewItem extends BaseActionViewItem {
labelElement.innerText = label;
reset(container, searchIcon, labelElement);
const hover = this._store.add(setupCustomHover(that._hoverDelegate, container, this.getTooltip()));
const hover = this._store.add(that._hoverService.setupUpdatableHover(that._hoverDelegate, container, this.getTooltip()));
// update label & tooltip when window title changes
this._store.add(that._windowTitle.onDidChange(() => {

View file

@ -4,13 +4,14 @@
*--------------------------------------------------------------------------------------------*/
import * as DOM from 'vs/base/browser/dom';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { Toggle } from 'vs/base/browser/ui/toggle/toggle';
import { Codicon } from 'vs/base/common/codicons';
import { Emitter, Event } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import type { IHoverService } from 'vs/platform/hover/browser/hover';
import { defaultToggleStyles } from 'vs/platform/theme/browser/defaultStyles';
import { ITreeItem, ITreeItemCheckboxState } from 'vs/workbench/common/views';
@ -27,14 +28,19 @@ export class TreeItemCheckbox extends Disposable {
public toggle: Toggle | undefined;
private checkboxContainer: HTMLDivElement;
public isDisposed = false;
private hover: ICustomHover | undefined;
private hover: IUpdatableHover | undefined;
public static readonly checkboxClass = 'custom-view-tree-node-item-checkbox';
private readonly _onDidChangeState = new Emitter<boolean>();
readonly onDidChangeState: Event<boolean> = this._onDidChangeState.event;
constructor(container: HTMLElement, private checkboxStateHandler: CheckboxStateHandler, private readonly hoverDelegate: IHoverDelegate) {
constructor(
container: HTMLElement,
private checkboxStateHandler: CheckboxStateHandler,
private readonly hoverDelegate: IHoverDelegate,
private readonly hoverService: IHoverService
) {
super();
this.checkboxContainer = <HTMLDivElement>container;
}
@ -81,7 +87,7 @@ export class TreeItemCheckbox extends Disposable {
private setHover(checkbox: ITreeItemCheckboxState) {
if (this.toggle) {
if (!this.hover) {
this.hover = this._register(setupCustomHover(this.hoverDelegate, this.toggle.domNode, this.checkboxHoverContent(checkbox)));
this.hover = this._register(this.hoverService.setupUpdatableHover(this.hoverDelegate, this.toggle.domNode, this.checkboxHoverContent(checkbox)));
} else {
this.hover.update(checkbox.tooltip);
}

View file

@ -9,7 +9,6 @@ import { renderMarkdownAsPlaintext } from 'vs/base/browser/markdownRenderer';
import { ActionBar, IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { ActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { IHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate';
import { ITooltipMarkdownString } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IIdentityProvider, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { ElementsDragAndDropData, ListViewTargetSector } from 'vs/base/browser/ui/list/listView';
import { IAsyncDataSource, ITreeContextMenuEvent, ITreeDragAndDrop, ITreeDragOverReaction, ITreeNode, ITreeRenderer, TreeDragOverBubble } from 'vs/base/browser/ui/tree/tree';
@ -73,6 +72,7 @@ import { TelemetryTrustedValue } from 'vs/platform/telemetry/common/telemetryUti
import { ITreeViewsDnDService } from 'vs/editor/common/services/treeViewsDndService';
import { DraggedTreeItemsIdentifier } from 'vs/editor/common/services/treeViewsDnd';
import { IMarkdownRenderResult, MarkdownRenderer } from 'vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
import type { IUpdatableHoverTooltipMarkdownString } from 'vs/base/browser/ui/hover/hover';
export class TreeViewPane extends ViewPane {
@ -91,9 +91,10 @@ export class TreeViewPane extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@INotificationService notificationService: INotificationService
@INotificationService notificationService: INotificationService,
@IHoverService hoverService: IHoverService
) {
super({ ...(options as IViewPaneOptions), titleMenuId: MenuId.ViewTitle, donotForwardArgs: false }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super({ ...(options as IViewPaneOptions), titleMenuId: MenuId.ViewTitle, donotForwardArgs: false }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
const { treeView } = (<ITreeViewDescriptor>Registry.as<IViewsRegistry>(Extensions.ViewsRegistry).getView(options.id));
this.treeView = treeView;
this._register(this.treeView.onDidChangeActions(() => this.updateActions(), this));
@ -1103,6 +1104,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
@ILabelService private readonly labelService: ILabelService,
@ITreeViewsService private readonly treeViewsService: ITreeViewsService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IHoverService private readonly hoverService: IHoverService,
@IInstantiationService instantiationService: IInstantiationService,
) {
super();
@ -1136,7 +1138,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
return { resourceLabel, icon, checkboxContainer, actionBar, container, elementDisposable: new DisposableStore() };
}
private getHover(label: string | undefined, resource: URI | null, node: ITreeItem): string | ITooltipMarkdownString | undefined {
private getHover(label: string | undefined, resource: URI | null, node: ITreeItem): string | IUpdatableHoverTooltipMarkdownString | undefined {
if (!(node instanceof ResolvableTreeItem) || !node.hasResolve) {
if (resource && !node.tooltip) {
return undefined;
@ -1286,7 +1288,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
this.rerender();
}
if (!templateData.checkbox) {
const checkbox = new TreeItemCheckbox(templateData.checkboxContainer, this.checkboxStateHandler, this._hoverDelegate);
const checkbox = new TreeItemCheckbox(templateData.checkboxContainer, this.checkboxStateHandler, this._hoverDelegate, this.hoverService);
templateData.checkbox = checkbox;
}
templateData.checkbox.render(node);

View file

@ -47,9 +47,10 @@ import { FilterWidget, IFilterWidgetOptions } from 'vs/workbench/browser/parts/v
import { BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { defaultButtonStyles, defaultProgressBarStyles } from 'vs/platform/theme/browser/defaultStyles';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export enum ViewPaneShowActions {
/** Show the actions when the view is hovered. This is the default behavior. */
@ -351,11 +352,11 @@ export abstract class ViewPane extends Pane implements IView {
private readonly showActions: ViewPaneShowActions;
private headerContainer?: HTMLElement;
private titleContainer?: HTMLElement;
private titleContainerHover?: ICustomHover;
private titleContainerHover?: IUpdatableHover;
private titleDescriptionContainer?: HTMLElement;
private titleDescriptionContainerHover?: ICustomHover;
private titleDescriptionContainerHover?: IUpdatableHover;
private iconContainer?: HTMLElement;
private iconContainerHover?: ICustomHover;
private iconContainerHover?: IUpdatableHover;
protected twistiesContainer?: HTMLElement;
private viewWelcomeController!: ViewWelcomeController;
@ -372,6 +373,7 @@ export abstract class ViewPane extends Pane implements IView {
@IOpenerService protected openerService: IOpenerService,
@IThemeService protected themeService: IThemeService,
@ITelemetryService protected telemetryService: ITelemetryService,
@IHoverService protected readonly hoverService: IHoverService
) {
super({ ...options, ...{ orientation: viewDescriptorService.getViewLocationById(options.id) === ViewContainerLocation.Panel ? Orientation.HORIZONTAL : Orientation.VERTICAL } });
@ -535,13 +537,13 @@ export abstract class ViewPane extends Pane implements IView {
const calculatedTitle = this.calculateTitle(title);
this.titleContainer = append(container, $('h3.title', {}, calculatedTitle));
this.titleContainerHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.titleContainer, calculatedTitle));
this.titleContainerHover = this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.titleContainer, calculatedTitle));
if (this._titleDescription) {
this.setTitleDescription(this._titleDescription);
}
this.iconContainerHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.iconContainer, calculatedTitle));
this.iconContainerHover = this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.iconContainer, calculatedTitle));
this.iconContainer.setAttribute('aria-label', calculatedTitle);
}
@ -568,7 +570,7 @@ export abstract class ViewPane extends Pane implements IView {
}
else if (description && this.titleContainer) {
this.titleDescriptionContainer = after(this.titleContainer, $('span.description', {}, description));
this.titleDescriptionContainerHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.titleDescriptionContainer, description));
this.titleDescriptionContainerHover = this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.titleDescriptionContainer, description));
}
}
@ -734,8 +736,9 @@ export abstract class FilterViewPane extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.filterWidget = this._register(instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService])).createInstance(FilterWidget, options.filterOptions));
}

View file

@ -43,8 +43,9 @@ import { IHostService } from 'vs/workbench/services/host/browser/host';
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { mainWindow } from 'vs/base/browser/window';
import { PixelRatio } from 'vs/base/browser/pixelRatio';
import { WorkbenchHoverDelegate } from 'vs/platform/hover/browser/hover';
import { IHoverService, WorkbenchHoverDelegate } from 'vs/platform/hover/browser/hover';
import { setHoverDelegateFactory } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { setBaseLayerHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegate2';
export interface IWorkbenchOptions {
@ -151,12 +152,14 @@ export class Workbench extends Layout {
const storageService = accessor.get(IStorageService);
const configurationService = accessor.get(IConfigurationService);
const hostService = accessor.get(IHostService);
const hoverService = accessor.get(IHoverService);
const dialogService = accessor.get(IDialogService);
const notificationService = accessor.get(INotificationService) as NotificationService;
// Default Hover Delegate must be registered before creating any workbench/layout components
// as these possibly will use the default hover delegate
setHoverDelegateFactory((placement, enableInstantHover) => instantiationService.createInstance(WorkbenchHoverDelegate, placement, enableInstantHover, {}));
setBaseLayerHoverDelegate(hoverService);
// Layout
this.initLayout(accessor);

View file

@ -40,6 +40,7 @@ import { IResourceDiffEditorInput } from 'vs/workbench/common/editor';
import { IMultiDiffEditorOptions, IMultiDiffResourceId } from 'vs/editor/browser/widget/multiDiffEditor/multiDiffEditorWidgetImpl';
import { IRange } from 'vs/editor/common/core/range';
import { CachedFunction, LRUCachedFunction } from 'vs/base/common/cache';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const enum State {
Data = 'data',
@ -89,10 +90,11 @@ export class BulkEditPane extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
) {
super(
{ ...options, titleMenuId: MenuId.BulkEditTitle },
keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, _instaService, openerService, themeService, telemetryService
keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, _instaService, openerService, themeService, telemetryService, hoverService
);
this.element.classList.add('bulk-edit-panel', 'show-file-icons');

View file

@ -8,6 +8,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
@ -60,11 +61,12 @@ export class ChatViewPane extends ViewPane implements IChatViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IStorageService private readonly storageService: IStorageService,
@IChatService private readonly chatService: IChatService,
@ILogService private readonly logService: ILogService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
// View state for the ViewPane is currently global per-provider basically, but some other strictly per-model state will require a separate memento.
this.memento = new Memento('interactive-session-view-' + this.chatViewOptions.providerId, this.storageService);

View file

@ -34,8 +34,8 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions, IConfigurationMigrationRegistry } from 'vs/workbench/common/configuration';
import { LOG_MODE_ID, OUTPUT_MODE_ID } from 'vs/workbench/services/output/common/output';
import { SEARCH_RESULT_LANGUAGE_ID } from 'vs/workbench/services/search/common/search';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = dom.$;
@ -73,6 +73,7 @@ export class EmptyTextEditorHintContribution implements IEditorContribution {
@IEditorGroupsService private readonly editorGroupsService: IEditorGroupsService,
@ICommandService private readonly commandService: ICommandService,
@IConfigurationService protected readonly configurationService: IConfigurationService,
@IHoverService protected readonly hoverService: IHoverService,
@IKeybindingService private readonly keybindingService: IKeybindingService,
@IInlineChatSessionService private readonly inlineChatSessionService: IInlineChatSessionService,
@IInlineChatService protected readonly inlineChatService: IInlineChatService,
@ -159,6 +160,7 @@ export class EmptyTextEditorHintContribution implements IEditorContribution {
this.editorGroupsService,
this.commandService,
this.configurationService,
this.hoverService,
this.keybindingService,
this.inlineChatService,
this.telemetryService,
@ -191,6 +193,7 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
private readonly editorGroupsService: IEditorGroupsService,
private readonly commandService: ICommandService,
private readonly configurationService: IConfigurationService,
private readonly hoverService: IHoverService,
private readonly keybindingService: IKeybindingService,
private readonly inlineChatService: IInlineChatService,
private readonly telemetryService: ITelemetryService,
@ -384,7 +387,7 @@ class EmptyTextEditorHintContentWidget implements IContentWidget {
anchor.style.cursor = 'pointer';
const id = keybindingsLookup.shift();
const title = id && this.keybindingService.lookupKeybinding(id)?.getLabel();
hintHandler.disposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), anchor, title ?? ''));
hintHandler.disposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), anchor, title ?? ''));
}
return { hintElement, ariaLabel };

View file

@ -25,6 +25,7 @@ import { status } from 'vs/base/browser/ui/aria/aria';
import { defaultInputBoxStyles, defaultToggleStyles } from 'vs/platform/theme/browser/defaultStyles';
import { ISashEvent, IVerticalSashLayoutProvider, Orientation, Sash } from 'vs/base/browser/ui/sash/sash';
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
import type { IHoverService } from 'vs/platform/hover/browser/hover';
const NLS_FIND_INPUT_LABEL = nls.localize('label.find', "Find");
const NLS_FIND_INPUT_PLACEHOLDER = nls.localize('placeholder.find', "Find");
@ -73,7 +74,8 @@ export abstract class SimpleFindWidget extends Widget implements IVerticalSashLa
options: IFindOptions,
contextViewService: IContextViewService,
contextKeyService: IContextKeyService,
private readonly _keybindingService: IKeybindingService
hoverService: IHoverService,
private readonly _keybindingService: IKeybindingService,
) {
super();
@ -143,7 +145,7 @@ export abstract class SimpleFindWidget extends Widget implements IVerticalSashLa
onTrigger: () => {
this.find(true);
}
}));
}, hoverService));
this.nextBtn = this._register(new SimpleButton({
label: NLS_NEXT_MATCH_BTN_LABEL + (options.nextMatchActionId ? this._getKeybinding(options.nextMatchActionId) : ''),
@ -151,7 +153,7 @@ export abstract class SimpleFindWidget extends Widget implements IVerticalSashLa
onTrigger: () => {
this.find(false);
}
}));
}, hoverService));
const closeBtn = this._register(new SimpleButton({
label: NLS_CLOSE_BTN_LABEL + (options.closeWidgetActionId ? this._getKeybinding(options.closeWidgetActionId) : ''),
@ -159,7 +161,7 @@ export abstract class SimpleFindWidget extends Widget implements IVerticalSashLa
onTrigger: () => {
this.hide();
}
}));
}, hoverService));
this._innerDomNode = document.createElement('div');
this._innerDomNode.classList.add('simple-find-part');

View file

@ -51,6 +51,7 @@ import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { MarshalledCommentThread } from 'vs/workbench/common/comments';
import { IHoverService } from 'vs/platform/hover/browser/hover';
class CommentsActionRunner extends ActionRunner {
protected override async runAction(action: IAction, context: any[]): Promise<void> {
@ -117,6 +118,7 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {
@IContextMenuService private contextMenuService: IContextMenuService,
@IContextKeyService contextKeyService: IContextKeyService,
@IConfigurationService private configurationService: IConfigurationService,
@IHoverService private hoverService: IHoverService,
@IAccessibilityService private accessibilityService: IAccessibilityService,
@IKeybindingService private keybindingService: IKeybindingService
) {
@ -250,7 +252,7 @@ export class CommentNode<T extends IRange | ICellRange> extends Disposable {
this._timestampWidget?.dispose();
} else {
if (!this._timestampWidget) {
this._timestampWidget = new TimestampWidget(this.configurationService, this._timestamp, timestamp);
this._timestampWidget = new TimestampWidget(this.configurationService, this.hoverService, this._timestamp, timestamp);
this._register(this._timestampWidget);
} else {
this._timestampWidget.setTimestamp(timestamp);

View file

@ -30,8 +30,8 @@ import { ICommentThreadWidget } from 'vs/workbench/contrib/comments/common/comme
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
import { LayoutableEditor, MIN_EDITOR_HEIGHT, SimpleCommentEditor, calculateEditorHeight } from './simpleCommentEditor';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const COMMENT_SCHEME = 'comment';
let INMEM_MODEL_ID = 0;
@ -67,7 +67,8 @@ export class CommentReply<T extends IRange | ICellRange> extends Disposable {
@IModelService private modelService: IModelService,
@IThemeService private themeService: IThemeService,
@IConfigurationService configurationService: IConfigurationService,
@IKeybindingService private keybindingService: IKeybindingService
@IKeybindingService private keybindingService: IKeybindingService,
@IHoverService private hoverService: IHoverService,
) {
super();
@ -357,7 +358,7 @@ export class CommentReply<T extends IRange | ICellRange> extends Disposable {
private createReplyButton(commentEditor: ICodeEditor, commentForm: HTMLElement) {
this._reviewThreadReplyButton = <HTMLButtonElement>dom.append(commentForm, dom.$(`button.review-thread-reply-button.${MOUSE_CURSOR_TEXT_CSS_CLASS_NAME}`));
this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this._reviewThreadReplyButton, this._commentOptions?.prompt || nls.localize('reply', "Reply...")));
this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this._reviewThreadReplyButton, this._commentOptions?.prompt || nls.localize('reply', "Reply...")));
this._reviewThreadReplyButton.textContent = this._commentOptions?.prompt || nls.localize('reply', "Reply...");
// bind click/escape actions for reviewThreadReplyButton and textArea

View file

@ -32,7 +32,6 @@ import { IStyleOverride } from 'vs/platform/theme/browser/defaultStyles';
import { IListStyles } from 'vs/base/browser/ui/list/listWidget';
import { ILocalizedString } from 'vs/platform/action/common/action';
import { CommentsModel } from 'vs/workbench/contrib/comments/browser/commentsModel';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ActionBar, IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { createActionViewItem, createAndFillInContextMenuActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
@ -43,6 +42,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { ActionViewItem } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { MarshalledCommentThread, MarshalledCommentThreadInternal } from 'vs/workbench/common/comments';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export const COMMENTS_VIEW_ID = 'workbench.panel.comments';
export const COMMENTS_VIEW_STORAGE_ID = 'Comments';
@ -191,6 +191,7 @@ export class CommentNodeRenderer implements IListRenderer<ITreeNode<CommentNode>
private menus: CommentsMenus,
@IOpenerService private readonly openerService: IOpenerService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IHoverService private readonly hoverService: IHoverService,
@IThemeService private themeService: IThemeService
) { }
@ -201,7 +202,7 @@ export class CommentNodeRenderer implements IListRenderer<ITreeNode<CommentNode>
const threadMetadata = {
icon: dom.append(metadata, dom.$('.icon')),
userNames: dom.append(metadata, dom.$('.user')),
timestamp: new TimestampWidget(this.configurationService, dom.append(metadata, dom.$('.timestamp-container'))),
timestamp: new TimestampWidget(this.configurationService, this.hoverService, dom.append(metadata, dom.$('.timestamp-container'))),
relevance: dom.append(metadata, dom.$('.relevance')),
separator: dom.append(metadata, dom.$('.separator')),
commentPreview: dom.append(metadata, dom.$('.text')),
@ -221,7 +222,7 @@ export class CommentNodeRenderer implements IListRenderer<ITreeNode<CommentNode>
count: dom.append(snippetContainer, dom.$('.count')),
lastReplyDetail: dom.append(snippetContainer, dom.$('.reply-detail')),
separator: dom.append(snippetContainer, dom.$('.separator')),
timestamp: new TimestampWidget(this.configurationService, dom.append(snippetContainer, dom.$('.timestamp-container'))),
timestamp: new TimestampWidget(this.configurationService, this.hoverService, dom.append(snippetContainer, dom.$('.timestamp-container'))),
};
repliesMetadata.separator.innerText = '\u00b7';
repliesMetadata.icon.classList.add(...ThemeIcon.asClassNameArray(Codicon.indent));
@ -300,7 +301,7 @@ export class CommentNodeRenderer implements IListRenderer<ITreeNode<CommentNode>
const renderedComment = this.getRenderedComment(originalComment.comment.body, disposables);
templateData.disposables.push(renderedComment);
templateData.threadMetadata.commentPreview.appendChild(renderedComment.element.firstElementChild ?? renderedComment.element);
templateData.disposables.push(setupCustomHover(getDefaultHoverDelegate('mouse'), templateData.threadMetadata.commentPreview, renderedComment.element.textContent ?? ''));
templateData.disposables.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), templateData.threadMetadata.commentPreview, renderedComment.element.textContent ?? ''));
}
if (node.element.range) {

View file

@ -34,6 +34,7 @@ import { Iterable } from 'vs/base/common/iterator';
import { revealCommentThread } from 'vs/workbench/contrib/comments/browser/commentsController';
import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands';
import { CommentsModel, ICommentsModel } from 'vs/workbench/contrib/comments/browser/commentsModel';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export const CONTEXT_KEY_HAS_COMMENTS = new RawContextKey<boolean>('commentsView.hasComments', false);
export const CONTEXT_KEY_SOME_COMMENTS_EXPANDED = new RawContextKey<boolean>('commentsView.someCommentsExpanded', false);
@ -80,6 +81,7 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
@IThemeService themeService: IThemeService,
@ICommentService private readonly commentService: ICommentService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IStorageService storageService: IStorageService
) {
@ -94,7 +96,7 @@ export class CommentsPanel extends FilterViewPane implements ICommentsView {
text: viewState['filter'] || '',
focusContextKey: CommentsViewFilterFocusContextKey.key
}
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.hasCommentsContextKey = CONTEXT_KEY_HAS_COMMENTS.bindTo(contextKeyService);
this.someCommentsExpandedContextKey = CONTEXT_KEY_SOME_COMMENTS_EXPANDED.bindTo(contextKeyService);
this.stateMemento = stateMemento;

View file

@ -4,12 +4,13 @@
*--------------------------------------------------------------------------------------------*/
import * as dom from 'vs/base/browser/dom';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { fromNow } from 'vs/base/common/date';
import { Disposable } from 'vs/base/common/lifecycle';
import { language } from 'vs/base/common/platform';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import type { IHoverService } from 'vs/platform/hover/browser/hover';
import { COMMENTS_SECTION, ICommentsConfiguration } from 'vs/workbench/contrib/comments/common/commentsConfiguration';
export class TimestampWidget extends Disposable {
@ -17,14 +18,19 @@ export class TimestampWidget extends Disposable {
private _timestamp: Date | undefined;
private _useRelativeTime: boolean;
private hover: ICustomHover;
private hover: IUpdatableHover;
constructor(private configurationService: IConfigurationService, container: HTMLElement, timeStamp?: Date) {
constructor(
private configurationService: IConfigurationService,
hoverService: IHoverService,
container: HTMLElement,
timeStamp?: Date
) {
super();
this._date = dom.append(container, dom.$('span.timestamp'));
this._date.style.display = 'none';
this._useRelativeTime = this.useRelativeTimeSetting;
this.hover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this._date, ''));
this.hover = this._register(hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this._date, ''));
this.setTimestamp(timeStamp);
}

View file

@ -19,6 +19,8 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
import { CancellationToken } from 'vs/base/common/cancellation';
import { URI, UriComponents } from 'vs/base/common/uri';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { NullHoverService } from 'vs/platform/hover/test/browser/nullHoverService';
class TestCommentThread implements CommentThread<IRange> {
isDocumentCommentThread(): this is CommentThread<IRange> {
@ -118,6 +120,7 @@ suite('Comments View', function () {
disposables = new DisposableStore();
instantiationService = workbenchInstantiationService({}, disposables);
instantiationService.stub(IConfigurationService, new TestConfigurationService());
instantiationService.stub(IHoverService, NullHoverService);
instantiationService.stub(IContextViewService, {});
instantiationService.stub(IViewDescriptorService, new TestViewDescriptorService());
commentService = instantiationService.createInstance(CommentService);

View file

@ -8,7 +8,6 @@ import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { HighlightedLabel, IHighlight } from 'vs/base/browser/ui/highlightedlabel/highlightedLabel';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IInputValidationOptions, InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
import { IAsyncDataSource, ITreeNode, ITreeRenderer } from 'vs/base/browser/ui/tree/tree';
import { Codicon } from 'vs/base/common/codicons';
@ -20,6 +19,7 @@ import { ThemeIcon } from 'vs/base/common/themables';
import { localize } from 'vs/nls';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { defaultInputBoxStyles } from 'vs/platform/theme/browser/defaultStyles';
import { COPY_EVALUATE_PATH_ID, COPY_VALUE_ID } from 'vs/workbench/contrib/debug/browser/debugCommands';
import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector';
@ -61,7 +61,7 @@ export function renderViewTree(container: HTMLElement): HTMLElement {
return treeContainer;
}
export function renderExpressionValue(expressionOrValue: IExpressionValue | string, container: HTMLElement, options: IRenderValueOptions): void {
export function renderExpressionValue(expressionOrValue: IExpressionValue | string, container: HTMLElement, options: IRenderValueOptions, hoverService: IHoverService): void {
let value = typeof expressionOrValue === 'string' ? expressionOrValue : expressionOrValue.value;
// remove stale classes
@ -109,7 +109,7 @@ export function renderExpressionValue(expressionOrValue: IExpressionValue | stri
if (options.hover) {
const { store, commands, commandService } = options.hover instanceof DisposableStore ? { store: options.hover, commands: [], commandService: undefined } : options.hover;
store.add(setupCustomHover(getDefaultHoverDelegate('mouse'), container, () => {
store.add(hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), container, () => {
const container = dom.$('div');
const markdownHoverElement = dom.$('div.hover-row');
const hoverContentsElement = dom.append(markdownHoverElement, dom.$('div.hover-contents'));
@ -130,7 +130,7 @@ export function renderExpressionValue(expressionOrValue: IExpressionValue | stri
}
}
export function renderVariable(store: DisposableStore, commandService: ICommandService, variable: Variable, data: IVariableTemplateData, showChanged: boolean, highlights: IHighlight[], linkDetector?: LinkDetector): void {
export function renderVariable(store: DisposableStore, commandService: ICommandService, hoverService: IHoverService, variable: Variable, data: IVariableTemplateData, showChanged: boolean, highlights: IHighlight[], linkDetector?: LinkDetector): void {
if (variable.available) {
let text = variable.name;
if (variable.value && typeof variable.name === 'string') {
@ -157,7 +157,7 @@ export function renderVariable(store: DisposableStore, commandService: ICommandS
hover: { store, commands, commandService },
colorize: true,
linkDetector
});
}, hoverService);
}
export interface IInputBoxOptions {
@ -217,6 +217,7 @@ export abstract class AbstractExpressionsRenderer<T = IExpression> implements IT
constructor(
@IDebugService protected debugService: IDebugService,
@IContextViewService private readonly contextViewService: IContextViewService,
@IHoverService protected readonly hoverService: IHoverService,
) { }
abstract get templateId(): string;
@ -227,7 +228,7 @@ export abstract class AbstractExpressionsRenderer<T = IExpression> implements IT
const name = dom.append(expression, $('span.name'));
const lazyButton = dom.append(expression, $('span.lazy-button'));
lazyButton.classList.add(...ThemeIcon.asClassNameArray(Codicon.eye));
templateDisposable.add(setupCustomHover(getDefaultHoverDelegate('mouse'), lazyButton, localize('debug.lazyButton.tooltip', "Click to expand")));
templateDisposable.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), lazyButton, localize('debug.lazyButton.tooltip', "Click to expand")));
const value = dom.append(expression, $('span.value'));
const label = templateDisposable.add(new HighlightedLabel(name));

View file

@ -10,7 +10,6 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { AriaRole } from 'vs/base/browser/ui/aria/aria';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IconLabel } from 'vs/base/browser/ui/iconLabel/iconLabel';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
import { IListContextMenuEvent, IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { IListAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
@ -114,10 +113,10 @@ export class BreakpointsView extends ViewPane {
@ITelemetryService telemetryService: ITelemetryService,
@ILabelService private readonly labelService: ILabelService,
@IMenuService menuService: IMenuService,
@IHoverService private readonly hoverService: IHoverService,
@IHoverService hoverService: IHoverService,
@ILanguageService private readonly languageService: ILanguageService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.menu = menuService.createMenu(MenuId.DebugBreakpointsContext, contextKeyService);
this._register(this.menu);
@ -141,12 +140,12 @@ export class BreakpointsView extends ViewPane {
this.list = this.instantiationService.createInstance(WorkbenchList, 'Breakpoints', container, delegate, [
this.instantiationService.createInstance(BreakpointsRenderer, this.menu, this.breakpointHasMultipleModes, this.breakpointSupportsCondition, this.breakpointItemType),
new ExceptionBreakpointsRenderer(this.menu, this.breakpointHasMultipleModes, this.breakpointSupportsCondition, this.breakpointItemType, this.debugService),
new ExceptionBreakpointsRenderer(this.menu, this.breakpointHasMultipleModes, this.breakpointSupportsCondition, this.breakpointItemType, this.debugService, this.hoverService),
new ExceptionBreakpointInputRenderer(this, this.debugService, this.contextViewService),
this.instantiationService.createInstance(FunctionBreakpointsRenderer, this.menu, this.breakpointSupportsCondition, this.breakpointItemType),
new FunctionBreakpointInputRenderer(this, this.debugService, this.contextViewService, this.labelService),
new FunctionBreakpointInputRenderer(this, this.debugService, this.contextViewService, this.hoverService, this.labelService),
this.instantiationService.createInstance(DataBreakpointsRenderer, this.menu, this.breakpointHasMultipleModes, this.breakpointSupportsCondition, this.breakpointItemType, this.breakpointIsDataBytes),
new DataBreakpointInputRenderer(this, this.debugService, this.contextViewService, this.labelService),
new DataBreakpointInputRenderer(this, this.debugService, this.contextViewService, this.hoverService, this.labelService),
this.instantiationService.createInstance(InstructionBreakpointsRenderer),
], {
identityProvider: { getId: (element: IEnablement) => element.getId() },
@ -499,6 +498,7 @@ class BreakpointsRenderer implements IListRenderer<IBreakpoint, IBreakpointTempl
private breakpointSupportsCondition: IContextKey<boolean>,
private breakpointItemType: IContextKey<string | undefined>,
@IDebugService private readonly debugService: IDebugService,
@IHoverService private readonly hoverService: IHoverService,
@ILabelService private readonly labelService: ILabelService
) {
// noop
@ -555,7 +555,7 @@ class BreakpointsRenderer implements IListRenderer<IBreakpoint, IBreakpointTempl
const { message, icon } = getBreakpointMessageAndIcon(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), breakpoint, this.labelService, this.debugService.getModel());
data.icon.className = ThemeIcon.asClassName(icon);
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.breakpoint, breakpoint.message || message || ''));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.breakpoint, breakpoint.message || message || ''));
const debugActive = this.debugService.state === State.Running || this.debugService.state === State.Stopped;
if (debugActive && !breakpoint.verified) {
@ -585,7 +585,8 @@ class ExceptionBreakpointsRenderer implements IListRenderer<IExceptionBreakpoint
private breakpointHasMultipleModes: IContextKey<boolean>,
private breakpointSupportsCondition: IContextKey<boolean>,
private breakpointItemType: IContextKey<string | undefined>,
private debugService: IDebugService
private debugService: IDebugService,
private readonly hoverService: IHoverService,
) {
// noop
}
@ -624,11 +625,11 @@ class ExceptionBreakpointsRenderer implements IListRenderer<IExceptionBreakpoint
data.context = exceptionBreakpoint;
data.name.textContent = exceptionBreakpoint.label || `${exceptionBreakpoint.filter} exceptions`;
const exceptionBreakpointtitle = exceptionBreakpoint.verified ? (exceptionBreakpoint.description || data.name.textContent) : exceptionBreakpoint.message || localize('unverifiedExceptionBreakpoint', "Unverified Exception Breakpoint");
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.breakpoint, exceptionBreakpointtitle));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.breakpoint, exceptionBreakpointtitle));
data.breakpoint.classList.toggle('disabled', !exceptionBreakpoint.verified);
data.checkbox.checked = exceptionBreakpoint.enabled;
data.condition.textContent = exceptionBreakpoint.condition || '';
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.condition, localize('expressionCondition', "Expression condition: {0}", exceptionBreakpoint.condition)));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.condition, localize('expressionCondition', "Expression condition: {0}", exceptionBreakpoint.condition)));
if (exceptionBreakpoint.modeLabel) {
data.badge.textContent = exceptionBreakpoint.modeLabel;
@ -659,6 +660,7 @@ class FunctionBreakpointsRenderer implements IListRenderer<FunctionBreakpoint, I
private breakpointSupportsCondition: IContextKey<boolean>,
private breakpointItemType: IContextKey<string | undefined>,
@IDebugService private readonly debugService: IDebugService,
@IHoverService private readonly hoverService: IHoverService,
@ILabelService private readonly labelService: ILabelService
) {
// noop
@ -700,9 +702,9 @@ class FunctionBreakpointsRenderer implements IListRenderer<FunctionBreakpoint, I
data.name.textContent = functionBreakpoint.name;
const { icon, message } = getBreakpointMessageAndIcon(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), functionBreakpoint, this.labelService, this.debugService.getModel());
data.icon.className = ThemeIcon.asClassName(icon);
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.icon, message ? message : ''));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.icon, message ? message : ''));
data.checkbox.checked = functionBreakpoint.enabled;
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.breakpoint, message ? message : ''));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.breakpoint, message ? message : ''));
if (functionBreakpoint.condition && functionBreakpoint.hitCondition) {
data.condition.textContent = localize('expressionAndHitCount', "Condition: {0} | Hit Count: {1}", functionBreakpoint.condition, functionBreakpoint.hitCondition);
} else {
@ -720,7 +722,7 @@ class FunctionBreakpointsRenderer implements IListRenderer<FunctionBreakpoint, I
const session = this.debugService.getViewModel().focusedSession;
data.breakpoint.classList.toggle('disabled', (session && !session.capabilities.supportsFunctionBreakpoints) || !this.debugService.getModel().areBreakpointsActivated());
if (session && !session.capabilities.supportsFunctionBreakpoints) {
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.breakpoint, localize('functionBreakpointsNotSupported', "Function breakpoints are not supported by this debug type")));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.breakpoint, localize('functionBreakpointsNotSupported', "Function breakpoints are not supported by this debug type")));
}
const primary: IAction[] = [];
@ -746,6 +748,7 @@ class DataBreakpointsRenderer implements IListRenderer<DataBreakpoint, IDataBrea
private breakpointItemType: IContextKey<string | undefined>,
private breakpointIsDataBytes: IContextKey<boolean | undefined>,
@IDebugService private readonly debugService: IDebugService,
@IHoverService private readonly hoverService: IHoverService,
@ILabelService private readonly labelService: ILabelService
) {
// noop
@ -788,9 +791,9 @@ class DataBreakpointsRenderer implements IListRenderer<DataBreakpoint, IDataBrea
data.name.textContent = dataBreakpoint.description;
const { icon, message } = getBreakpointMessageAndIcon(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), dataBreakpoint, this.labelService, this.debugService.getModel());
data.icon.className = ThemeIcon.asClassName(icon);
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.icon, message ? message : ''));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.icon, message ? message : ''));
data.checkbox.checked = dataBreakpoint.enabled;
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.breakpoint, message ? message : ''));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.breakpoint, message ? message : ''));
if (dataBreakpoint.modeLabel) {
data.badge.textContent = dataBreakpoint.modeLabel;
@ -803,7 +806,7 @@ class DataBreakpointsRenderer implements IListRenderer<DataBreakpoint, IDataBrea
const session = this.debugService.getViewModel().focusedSession;
data.breakpoint.classList.toggle('disabled', (session && !session.capabilities.supportsDataBreakpoints) || !this.debugService.getModel().areBreakpointsActivated());
if (session && !session.capabilities.supportsDataBreakpoints) {
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.breakpoint, localize('dataBreakpointsNotSupported', "Data breakpoints are not supported by this debug type")));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.breakpoint, localize('dataBreakpointsNotSupported', "Data breakpoints are not supported by this debug type")));
}
if (dataBreakpoint.accessType) {
const accessType = dataBreakpoint.accessType === 'read' ? localize('read', "Read") : dataBreakpoint.accessType === 'write' ? localize('write', "Write") : localize('access', "Access");
@ -838,6 +841,7 @@ class InstructionBreakpointsRenderer implements IListRenderer<IInstructionBreakp
constructor(
@IDebugService private readonly debugService: IDebugService,
@IHoverService private readonly hoverService: IHoverService,
@ILabelService private readonly labelService: ILabelService
) {
// noop
@ -879,12 +883,12 @@ class InstructionBreakpointsRenderer implements IListRenderer<IInstructionBreakp
data.breakpoint.classList.toggle('disabled', !this.debugService.getModel().areBreakpointsActivated());
data.name.textContent = '0x' + breakpoint.address.toString(16);
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.name, `Decimal address: breakpoint.address.toString()`));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.name, `Decimal address: breakpoint.address.toString()`));
data.checkbox.checked = breakpoint.enabled;
const { message, icon } = getBreakpointMessageAndIcon(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), breakpoint, this.labelService, this.debugService.getModel());
data.icon.className = ThemeIcon.asClassName(icon);
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.breakpoint, breakpoint.message || message || ''));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.breakpoint, breakpoint.message || message || ''));
const debugActive = this.debugService.state === State.Running || this.debugService.state === State.Stopped;
if (debugActive && !breakpoint.verified) {
@ -910,6 +914,7 @@ class FunctionBreakpointInputRenderer implements IListRenderer<IFunctionBreakpoi
private view: BreakpointsView,
private debugService: IDebugService,
private contextViewService: IContextViewService,
private readonly hoverService: IHoverService,
private labelService: ILabelService
) { }
@ -989,7 +994,7 @@ class FunctionBreakpointInputRenderer implements IListRenderer<IFunctionBreakpoi
const { icon, message } = getBreakpointMessageAndIcon(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), functionBreakpoint, this.labelService, this.debugService.getModel());
data.icon.className = ThemeIcon.asClassName(icon);
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.icon, message ? message : ''));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.icon, message ? message : ''));
data.checkbox.checked = functionBreakpoint.enabled;
data.checkbox.disabled = true;
data.inputBox.value = functionBreakpoint.name || '';
@ -1025,6 +1030,7 @@ class DataBreakpointInputRenderer implements IListRenderer<IDataBreakpoint, IDat
private view: BreakpointsView,
private debugService: IDebugService,
private contextViewService: IContextViewService,
private readonly hoverService: IHoverService,
private labelService: ILabelService
) { }
@ -1097,7 +1103,7 @@ class DataBreakpointInputRenderer implements IListRenderer<IDataBreakpoint, IDat
const { icon, message } = getBreakpointMessageAndIcon(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), dataBreakpoint, this.labelService, this.debugService.getModel());
data.icon.className = ThemeIcon.asClassName(icon);
data.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.icon, message ?? ''));
data.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.icon, message ?? ''));
data.checkbox.checked = dataBreakpoint.enabled;
data.checkbox.disabled = true;
data.inputBox.value = '';

View file

@ -48,8 +48,9 @@ import { createDisconnectMenuItemAction } from 'vs/workbench/contrib/debug/brows
import { CALLSTACK_VIEW_ID, CONTEXT_CALLSTACK_ITEM_STOPPED, CONTEXT_CALLSTACK_ITEM_TYPE, CONTEXT_CALLSTACK_SESSION_HAS_ONE_THREAD, CONTEXT_CALLSTACK_SESSION_IS_ATTACH, CONTEXT_DEBUG_STATE, CONTEXT_FOCUSED_SESSION_IS_NO_DEBUG, CONTEXT_STACK_FRAME_SUPPORTS_RESTART, getStateLabel, IDebugModel, IDebugService, IDebugSession, IRawStoppedDetails, isFrameDeemphasized, IStackFrame, IThread, State } from 'vs/workbench/contrib/debug/common/debug';
import { StackFrame, Thread, ThreadAndSessionIds } from 'vs/workbench/contrib/debug/common/debugModel';
import { isSessionAttach } from 'vs/workbench/contrib/debug/common/debugUtils';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = dom.$;
@ -135,7 +136,7 @@ async function expandTo(session: IDebugSession, tree: WorkbenchCompressibleAsync
export class CallStackView extends ViewPane {
private stateMessage!: HTMLSpanElement;
private stateMessageLabel!: HTMLSpanElement;
private stateMessageLabelHover!: ICustomHover;
private stateMessageLabelHover!: IUpdatableHover;
private onCallStackChangeScheduler: RunOnceScheduler;
private needsRefresh = false;
private ignoreSelectionChangedEvent = false;
@ -158,9 +159,10 @@ export class CallStackView extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IMenuService private readonly menuService: IMenuService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
// Create scheduler to prevent unnecessary flashing of tree when reacting to changes
this.onCallStackChangeScheduler = this._register(new RunOnceScheduler(async () => {
@ -219,7 +221,7 @@ export class CallStackView extends ViewPane {
this.stateMessage = dom.append(container, $('span.call-stack-state-message'));
this.stateMessage.hidden = true;
this.stateMessageLabel = dom.append(this.stateMessage, $('span.label'));
this.stateMessageLabelHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.stateMessage, ''));
this.stateMessageLabelHover = this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.stateMessage, ''));
}
protected override renderBody(container: HTMLElement): void {
@ -233,7 +235,7 @@ export class CallStackView extends ViewPane {
this.instantiationService.createInstance(SessionsRenderer),
this.instantiationService.createInstance(ThreadsRenderer),
this.instantiationService.createInstance(StackFramesRenderer),
new ErrorsRenderer(),
this.instantiationService.createInstance(ErrorsRenderer),
new LoadMoreRenderer(),
new ShowMoreRenderer()
], this.dataSource, {
@ -530,6 +532,7 @@ class SessionsRenderer implements ICompressibleTreeRenderer<IDebugSession, Fuzzy
constructor(
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IHoverService private readonly hoverService: IHoverService,
@IMenuService private readonly menuService: IMenuService,
) { }
@ -581,7 +584,7 @@ class SessionsRenderer implements ICompressibleTreeRenderer<IDebugSession, Fuzzy
}
private doRenderElement(session: IDebugSession, matches: IMatch[], data: ISessionTemplateData): void {
const sessionHover = data.elementDisposable.add(setupCustomHover(getDefaultHoverDelegate('mouse'), data.session, localize({ key: 'session', comment: ['Session is a noun'] }, "Session")));
const sessionHover = data.elementDisposable.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.session, localize({ key: 'session', comment: ['Session is a noun'] }, "Session")));
data.label.set(session.getLabel(), matches);
const stoppedDetails = session.getStoppedDetails();
const thread = session.getAllThreads().find(t => t.stopped);
@ -646,6 +649,7 @@ class ThreadsRenderer implements ICompressibleTreeRenderer<IThread, FuzzyScore,
constructor(
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IHoverService private readonly hoverService: IHoverService,
@IMenuService private readonly menuService: IMenuService,
) { }
@ -669,7 +673,7 @@ class ThreadsRenderer implements ICompressibleTreeRenderer<IThread, FuzzyScore,
renderElement(element: ITreeNode<IThread, FuzzyScore>, _index: number, data: IThreadTemplateData): void {
const thread = element.element;
data.elementDisposable.add(setupCustomHover(getDefaultHoverDelegate('mouse'), data.thread, thread.name));
data.elementDisposable.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.thread, thread.name));
data.label.set(thread.name, createMatches(element.filterData));
data.stateLabel.textContent = thread.stateLabel;
data.stateLabel.classList.toggle('exception', thread.stoppedDetails?.reason === 'exception');
@ -718,6 +722,7 @@ class StackFramesRenderer implements ICompressibleTreeRenderer<IStackFrame, Fuzz
static readonly ID = 'stackFrame';
constructor(
@IHoverService private readonly hoverService: IHoverService,
@ILabelService private readonly labelService: ILabelService,
@INotificationService private readonly notificationService: INotificationService,
) { }
@ -753,7 +758,7 @@ class StackFramesRenderer implements ICompressibleTreeRenderer<IStackFrame, Fuzz
if (stackFrame.source.raw.origin) {
title += `\n${stackFrame.source.raw.origin}`;
}
data.templateDisposable.add(setupCustomHover(getDefaultHoverDelegate('mouse'), data.file, title));
data.templateDisposable.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.file, title));
data.label.set(stackFrame.name, createMatches(element.filterData), stackFrame.name);
data.fileName.textContent = getSpecificSourceName(stackFrame);
@ -796,6 +801,11 @@ class ErrorsRenderer implements ICompressibleTreeRenderer<string, FuzzyScore, IE
return ErrorsRenderer.ID;
}
constructor(
@IHoverService private readonly hoverService: IHoverService
) {
}
renderTemplate(container: HTMLElement): IErrorTemplateData {
const label = dom.append(container, $('.error'));
@ -805,7 +815,7 @@ class ErrorsRenderer implements ICompressibleTreeRenderer<string, FuzzyScore, IE
renderElement(element: ITreeNode<string, FuzzyScore>, index: number, data: IErrorTemplateData): void {
const error = element.element;
data.label.textContent = error;
data.templateDisposable.add(setupCustomHover(getDefaultHoverDelegate('mouse'), data.label, error));
data.templateDisposable.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.label, error));
}
renderCompressedElements(node: ITreeNode<ICompressedTreeNode<string>, FuzzyScore>, index: number, templateData: IErrorTemplateData, height: number | undefined): void {

View file

@ -22,8 +22,8 @@ import { BaseActionViewItem, IBaseActionViewItemOptions, SelectActionViewItem }
import { debugStart } from 'vs/workbench/contrib/debug/browser/debugIcons';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { defaultSelectBoxStyles } from 'vs/platform/theme/browser/defaultStyles';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = dom.$;
@ -48,7 +48,8 @@ export class StartDebugActionViewItem extends BaseActionViewItem {
@ICommandService private readonly commandService: ICommandService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IContextViewService contextViewService: IContextViewService,
@IKeybindingService private readonly keybindingService: IKeybindingService
@IKeybindingService private readonly keybindingService: IKeybindingService,
@IHoverService private readonly hoverService: IHoverService
) {
super(context, action, options);
this.toDispose = [];
@ -77,7 +78,7 @@ export class StartDebugActionViewItem extends BaseActionViewItem {
const keybinding = this.keybindingService.lookupKeybinding(this.action.id)?.getLabel();
const keybindingLabel = keybinding ? ` (${keybinding})` : '';
const title = this.action.label + keybindingLabel;
this.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), this.start, title));
this.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.start, title));
this.start.setAttribute('role', 'button');
this.start.ariaLabel = title;

View file

@ -28,6 +28,7 @@ import * as nls from 'vs/nls';
import { IMenuService, MenuId } from 'vs/platform/actions/common/actions';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
import { ILogService } from 'vs/platform/log/common/log';
@ -110,6 +111,7 @@ export class DebugHoverWidget implements IContentWidget {
@IMenuService private readonly menuService: IMenuService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IHoverService private readonly hoverService: IHoverService,
) {
this.toDispose = [];
@ -289,7 +291,7 @@ export class DebugHoverWidget implements IContentWidget {
renderExpressionValue(expression, this.valueContainer, {
showChanged: false,
colorize: true
});
}, this.hoverService);
this.valueContainer.title = '';
this.editor.layoutContentWidget(this);
this.scrollbar.scanDomNode();

View file

@ -43,6 +43,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
import { TreeFindMode } from 'vs/base/browser/ui/tree/abstractTree';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const NEW_STYLE_COMPRESS = true;
@ -437,9 +438,10 @@ export class LoadedScriptsView extends ViewPane {
@IPathService private readonly pathService: IPathService,
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.loadedScriptsItemType = CONTEXT_LOADED_SCRIPTS_ITEM_TYPE.bindTo(contextKeyService);
}

View file

@ -71,6 +71,7 @@ import { ReplEvaluationResult, ReplGroup } from 'vs/workbench/contrib/debug/comm
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands';
import { AccessibilitySignal, IAccessibilitySignalService } from 'vs/platform/accessibilitySignal/browser/accessibilitySignalService';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = dom.$;
@ -133,6 +134,7 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget {
@IKeybindingService keybindingService: IKeybindingService,
@IOpenerService openerService: IOpenerService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IMenuService menuService: IMenuService,
@ILanguageFeaturesService private readonly languageFeaturesService: ILanguageFeaturesService,
@ILogService private readonly logService: ILogService,
@ -145,7 +147,7 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget {
text: filterText,
history: JSON.parse(storageService.get(FILTER_HISTORY_STORAGE_KEY, StorageScope.WORKSPACE, '[]')) as string[],
}
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.menu = menuService.createMenu(MenuId.DebugConsoleContext, contextKeyService);
this._register(this.menu);
@ -623,8 +625,8 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget {
this.instantiationService.createInstance(ReplOutputElementRenderer, linkDetector),
new ReplEvaluationInputsRenderer(),
this.instantiationService.createInstance(ReplGroupRenderer, linkDetector),
new ReplEvaluationResultsRenderer(linkDetector),
new ReplRawObjectsRenderer(linkDetector),
new ReplEvaluationResultsRenderer(linkDetector, this.hoverService),
new ReplRawObjectsRenderer(linkDetector, this.hoverService),
],
// https://github.com/microsoft/TypeScript/issues/32526
new ReplDataSource() satisfies IAsyncDataSource<IDebugSession, IReplElement>,

View file

@ -28,9 +28,9 @@ import { IDebugConfiguration, IDebugService, IDebugSession, IExpression, IExpres
import { Variable } from 'vs/workbench/contrib/debug/common/debugModel';
import { RawObjectReplElement, ReplEvaluationInput, ReplEvaluationResult, ReplGroup, ReplOutputElement, ReplVariableElement } from 'vs/workbench/contrib/debug/common/replModel';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = dom.$;
@ -125,7 +125,10 @@ export class ReplEvaluationResultsRenderer implements ITreeRenderer<ReplEvaluati
return ReplEvaluationResultsRenderer.ID;
}
constructor(private readonly linkDetector: LinkDetector) { }
constructor(
private readonly linkDetector: LinkDetector,
private readonly hoverService: IHoverService
) { }
renderTemplate(container: HTMLElement): IReplEvaluationResultTemplateData {
const output = dom.append(container, $('.evaluation-result.expression'));
@ -139,7 +142,7 @@ export class ReplEvaluationResultsRenderer implements ITreeRenderer<ReplEvaluati
renderExpressionValue(expression, templateData.value, {
colorize: true,
linkDetector: this.linkDetector
});
}, this.hoverService);
}
disposeTemplate(templateData: IReplEvaluationResultTemplateData): void {
@ -153,6 +156,7 @@ export class ReplOutputElementRenderer implements ITreeRenderer<ReplOutputElemen
constructor(
private readonly linkDetector: LinkDetector,
@IEditorService private readonly editorService: IEditorService,
@IHoverService private readonly hoverService: IHoverService,
@ILabelService private readonly labelService: ILabelService,
@IThemeService private readonly themeService: IThemeService
) { }
@ -201,7 +205,7 @@ export class ReplOutputElementRenderer implements ITreeRenderer<ReplOutputElemen
templateData.value.classList.add((element.severity === severity.Warning) ? 'warn' : (element.severity === severity.Error) ? 'error' : (element.severity === severity.Ignore) ? 'ignore' : 'info');
templateData.source.textContent = element.sourceData ? `${basename(element.sourceData.source.name)}:${element.sourceData.lineNumber}` : '';
templateData.toDispose.push(setupCustomHover(getDefaultHoverDelegate('mouse'), templateData.source, element.sourceData ? `${this.labelService.getUriLabel(element.sourceData.source.uri)}:${element.sourceData.lineNumber}` : ''));
templateData.toDispose.push(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), templateData.source, element.sourceData ? `${this.labelService.getUriLabel(element.sourceData.source.uri)}:${element.sourceData.lineNumber}` : ''));
templateData.getReplElementSource = () => element.sourceData;
}
@ -236,8 +240,9 @@ export class ReplVariablesRenderer extends AbstractExpressionsRenderer<IExpressi
@IDebugService debugService: IDebugService,
@IContextViewService contextViewService: IContextViewService,
@ICommandService private readonly commandService: ICommandService,
@IHoverService hoverService: IHoverService
) {
super(debugService, contextViewService);
super(debugService, contextViewService, hoverService);
}
public renderElement(node: ITreeNode<IExpression | ReplVariableElement, FuzzyScore>, _index: number, data: IExpressionTemplateData): void {
@ -249,10 +254,10 @@ export class ReplVariablesRenderer extends AbstractExpressionsRenderer<IExpressi
const isReplVariable = expression instanceof ReplVariableElement;
if (isReplVariable || !expression.name) {
data.label.set('');
renderExpressionValue(isReplVariable ? expression.expression : expression, data.value, { colorize: true, linkDetector: this.linkDetector });
renderExpressionValue(isReplVariable ? expression.expression : expression, data.value, { colorize: true, linkDetector: this.linkDetector }, this.hoverService);
data.expression.classList.remove('nested-variable');
} else {
renderVariable(data.elementDisposable, this.commandService, expression as Variable, data, true, highlights, this.linkDetector);
renderVariable(data.elementDisposable, this.commandService, this.hoverService, expression as Variable, data, true, highlights, this.linkDetector);
data.expression.classList.toggle('nested-variable', isNestedVariable(expression));
}
}
@ -265,7 +270,10 @@ export class ReplVariablesRenderer extends AbstractExpressionsRenderer<IExpressi
export class ReplRawObjectsRenderer implements ITreeRenderer<RawObjectReplElement, FuzzyScore, IRawObjectReplTemplateData> {
static readonly ID = 'rawObject';
constructor(private readonly linkDetector: LinkDetector) { }
constructor(
private readonly linkDetector: LinkDetector,
private readonly hoverService: IHoverService
) { }
get templateId(): string {
return ReplRawObjectsRenderer.ID;
@ -295,7 +303,7 @@ export class ReplRawObjectsRenderer implements ITreeRenderer<RawObjectReplElemen
// value
renderExpressionValue(element.value, templateData.value, {
linkDetector: this.linkDetector
});
}, this.hoverService);
}
disposeTemplate(templateData: IRawObjectReplTemplateData): void {

View file

@ -26,6 +26,7 @@ import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/c
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
@ -80,9 +81,10 @@ export class VariablesView extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IMenuService private readonly menuService: IMenuService
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
// Use scheduler to prevent unnecessary flashing
this.updateTreeScheduler = new RunOnceScheduler(async () => {
@ -443,10 +445,11 @@ export class VisualizedVariableRenderer extends AbstractExpressionsRenderer {
private readonly linkDetector: LinkDetector,
@IDebugService debugService: IDebugService,
@IContextViewService contextViewService: IContextViewService,
@IHoverService hoverService: IHoverService,
@IMenuService private readonly menuService: IMenuService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
) {
super(debugService, contextViewService);
super(debugService, contextViewService, hoverService);
}
public override get templateId(): string {
@ -471,7 +474,7 @@ export class VisualizedVariableRenderer extends AbstractExpressionsRenderer {
hover: data.elementDisposable,
colorize: true,
linkDetector: this.linkDetector
});
}, this.hoverService);
}
protected override getInputBoxOptions(expression: IExpression): IInputBoxOptions | undefined {
@ -529,8 +532,9 @@ export class VariablesRenderer extends AbstractExpressionsRenderer {
@ICommandService private readonly commandService: ICommandService,
@IDebugService debugService: IDebugService,
@IContextViewService contextViewService: IContextViewService,
@IHoverService hoverService: IHoverService,
) {
super(debugService, contextViewService);
super(debugService, contextViewService, hoverService);
}
get templateId(): string {
@ -538,7 +542,7 @@ export class VariablesRenderer extends AbstractExpressionsRenderer {
}
protected renderExpression(expression: IExpression, data: IExpressionTemplateData, highlights: IHighlight[]): void {
renderVariable(data.elementDisposable, this.commandService, expression as Variable, data, true, highlights, this.linkDetector);
renderVariable(data.elementDisposable, this.commandService, this.hoverService, expression as Variable, data, true, highlights, this.linkDetector);
}
public override renderElement(node: ITreeNode<IExpression, FuzzyScore>, index: number, data: IExpressionTemplateData): void {

View file

@ -20,6 +20,7 @@ import { Action2, IMenu, IMenuService, MenuId, registerAction2 } from 'vs/platfo
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
@ -62,9 +63,10 @@ export class WatchExpressionsView extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IMenuService menuService: IMenuService
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.menu = menuService.createMenu(MenuId.DebugWatchContext, contextKeyService);
this._register(this.menu);
@ -283,8 +285,9 @@ class WatchExpressionsRenderer extends AbstractExpressionsRenderer {
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IDebugService debugService: IDebugService,
@IContextViewService contextViewService: IContextViewService,
@IHoverService hoverService: IHoverService,
) {
super(debugService, contextViewService);
super(debugService, contextViewService, hoverService);
}
get templateId() {
@ -312,7 +315,7 @@ class WatchExpressionsRenderer extends AbstractExpressionsRenderer {
maxValueLength: MAX_VALUE_RENDER_LENGTH_IN_VIEWLET,
hover: data.elementDisposable,
colorize: true
});
}, this.hoverService);
}
protected getInputBoxOptions(expression: IExpression, settingValue: boolean): IInputBoxOptions {

View file

@ -26,6 +26,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { SELECT_AND_START_ID, DEBUG_CONFIGURE_COMMAND_ID, DEBUG_START_COMMAND_ID } from 'vs/workbench/contrib/debug/browser/debugCommands';
import { ILocalizedString } from 'vs/platform/action/common/action';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const debugStartLanguageKey = 'debugStartLanguage';
const CONTEXT_DEBUG_START_LANGUAGE = new RawContextKey<string>(debugStartLanguageKey, undefined);
@ -53,8 +54,9 @@ export class WelcomeView extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IStorageService storageSevice: IStorageService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.debugStartLanguageContext = CONTEXT_DEBUG_START_LANGUAGE.bindTo(contextKeyService);
this.debuggerInterestedContext = CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR.bindTo(contextKeyService);

View file

@ -10,6 +10,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import { isWindows } from 'vs/base/common/platform';
import { ensureNoDisposablesAreLeakedInTestSuite } from 'vs/base/test/common/utils';
import { NullCommandService } from 'vs/platform/commands/test/common/nullCommandService';
import { NullHoverService } from 'vs/platform/hover/test/browser/nullHoverService';
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
import { renderExpressionValue, renderVariable, renderViewTree } from 'vs/workbench/contrib/debug/browser/baseDebugView';
import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector';
@ -46,37 +47,37 @@ suite('Debug - Base Debug View', () => {
test('render expression value', () => {
let container = $('.container');
renderExpressionValue('render \n me', container, {});
renderExpressionValue('render \n me', container, {}, NullHoverService);
assert.strictEqual(container.className, 'value');
assert.strictEqual(container.textContent, 'render \n me');
const expression = new Expression('console');
expression.value = 'Object';
container = $('.container');
renderExpressionValue(expression, container, { colorize: true });
renderExpressionValue(expression, container, { colorize: true }, NullHoverService);
assert.strictEqual(container.className, 'value unavailable error');
expression.available = true;
expression.value = '"string value"';
container = $('.container');
renderExpressionValue(expression, container, { colorize: true, linkDetector });
renderExpressionValue(expression, container, { colorize: true, linkDetector }, NullHoverService);
assert.strictEqual(container.className, 'value string');
assert.strictEqual(container.textContent, '"string value"');
expression.type = 'boolean';
container = $('.container');
renderExpressionValue(expression, container, { colorize: true });
renderExpressionValue(expression, container, { colorize: true }, NullHoverService);
assert.strictEqual(container.className, 'value boolean');
assert.strictEqual(container.textContent, expression.value);
expression.value = 'this is a long string';
container = $('.container');
renderExpressionValue(expression, container, { colorize: true, maxValueLength: 4, linkDetector });
renderExpressionValue(expression, container, { colorize: true, maxValueLength: 4, linkDetector }, NullHoverService);
assert.strictEqual(container.textContent, 'this...');
expression.value = isWindows ? 'C:\\foo.js:5' : '/foo.js:5';
container = $('.container');
renderExpressionValue(expression, container, { colorize: true, linkDetector });
renderExpressionValue(expression, container, { colorize: true, linkDetector }, NullHoverService);
assert.ok(container.querySelector('a'));
assert.strictEqual(container.querySelector('a')!.textContent, expression.value);
});
@ -94,7 +95,7 @@ suite('Debug - Base Debug View', () => {
const label = new HighlightedLabel(name);
const lazyButton = $('.');
const store = disposables.add(new DisposableStore());
renderVariable(store, NullCommandService, variable, { expression, name, value, label, lazyButton }, false, []);
renderVariable(store, NullCommandService, NullHoverService, variable, { expression, name, value, label, lazyButton }, false, []);
assert.strictEqual(label.element.textContent, 'foo');
assert.strictEqual(value.textContent, '');
@ -103,7 +104,7 @@ suite('Debug - Base Debug View', () => {
expression = $('.');
name = $('.');
value = $('.');
renderVariable(store, NullCommandService, variable, { expression, name, value, label, lazyButton }, false, [], linkDetector);
renderVariable(store, NullCommandService, NullHoverService, variable, { expression, name, value, label, lazyButton }, false, [], linkDetector);
assert.strictEqual(value.textContent, 'hey');
assert.strictEqual(label.element.textContent, 'foo:');
@ -111,7 +112,7 @@ suite('Debug - Base Debug View', () => {
expression = $('.');
name = $('.');
value = $('.');
renderVariable(store, NullCommandService, variable, { expression, name, value, label, lazyButton }, false, [], linkDetector);
renderVariable(store, NullCommandService, NullHoverService, variable, { expression, name, value, label, lazyButton }, false, [], linkDetector);
assert.ok(value.querySelector('a'));
assert.strictEqual(value.querySelector('a')!.textContent, variable.value);
@ -119,7 +120,7 @@ suite('Debug - Base Debug View', () => {
expression = $('.');
name = $('.');
value = $('.');
renderVariable(store, NullCommandService, variable, { expression, name, value, label, lazyButton }, false, [], linkDetector);
renderVariable(store, NullCommandService, NullHoverService, variable, { expression, name, value, label, lazyButton }, false, [], linkDetector);
assert.strictEqual(name.className, 'virtual');
assert.strictEqual(label.element.textContent, 'console:');
assert.strictEqual(value.className, 'value number');

View file

@ -6,7 +6,6 @@
import { $, Dimension, addDisposableListener, append, clearNode } from 'vs/base/browser/dom';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { IListAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
@ -25,6 +24,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { ExtensionIdentifier, ExtensionIdentifierMap, IExtensionDescription } from 'vs/platform/extensions/common/extensions';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ILabelService } from 'vs/platform/label/common/label';
import { WorkbenchList } from 'vs/platform/list/browser/listService';
@ -92,6 +92,7 @@ export abstract class AbstractRuntimeExtensionsEditor extends EditorPane {
@IWorkbenchEnvironmentService private readonly _environmentService: IWorkbenchEnvironmentService,
@IClipboardService private readonly _clipboardService: IClipboardService,
@IExtensionFeaturesManagementService private readonly _extensionFeaturesManagementService: IExtensionFeaturesManagementService,
@IHoverService private readonly _hoverService: IHoverService,
) {
super(AbstractRuntimeExtensionsEditor.ID, group, telemetryService, themeService, storageService);
@ -368,14 +369,14 @@ export abstract class AbstractRuntimeExtensionsEditor extends EditorPane {
} else {
title = nls.localize('extensionActivating', "Extension is activating...");
}
data.elementDisposables.push(setupCustomHover(getDefaultHoverDelegate('mouse'), data.activationTime, title));
data.elementDisposables.push(this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), data.activationTime, title));
clearNode(data.msgContainer);
if (this._getUnresponsiveProfile(element.description.identifier)) {
const el = $('span', undefined, ...renderLabelWithIcons(` $(alert) Unresponsive`));
const extensionHostFreezTitle = nls.localize('unresponsive.title', "Extension has caused the extension host to freeze.");
data.elementDisposables.push(setupCustomHover(getDefaultHoverDelegate('mouse'), el, extensionHostFreezTitle));
data.elementDisposables.push(this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), el, extensionHostFreezTitle));
data.msgContainer.appendChild(el);
}
@ -423,7 +424,7 @@ export abstract class AbstractRuntimeExtensionsEditor extends EditorPane {
if (accessData?.current) {
const element = $('span', undefined, nls.localize('requests count', "{0} Requests: {1} (Session)", feature.label, accessData.current.count));
const title = nls.localize('requests count title', "Last request was {0}. Overall Requests: {1}", fromNow(accessData.current.lastAccessed, true, true), accessData.totalCount);
data.elementDisposables.push(setupCustomHover(getDefaultHoverDelegate('mouse'), element, title));
data.elementDisposables.push(this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), element, title));
data.msgContainer.appendChild(element);
}

View file

@ -6,7 +6,6 @@
import { $, Dimension, addDisposableListener, append, setParentFlowTo } from 'vs/base/browser/dom';
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { DomScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
import { CheckboxActionViewItem } from 'vs/base/browser/ui/toggle/toggle';
import { Action, IAction } from 'vs/base/common/actions';
@ -91,6 +90,7 @@ import { IPaneCompositePartService } from 'vs/workbench/services/panecomposite/b
import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
import { VIEW_ID as EXPLORER_VIEW_ID } from 'vs/workbench/contrib/files/common/files';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { IHoverService } from 'vs/platform/hover/browser/hover';
class NavBar extends Disposable {
@ -195,10 +195,13 @@ abstract class ExtensionWithDifferentGalleryVersionWidget extends ExtensionWidge
class VersionWidget extends ExtensionWithDifferentGalleryVersionWidget {
private readonly element: HTMLElement;
constructor(container: HTMLElement) {
constructor(
container: HTMLElement,
hoverService: IHoverService
) {
super();
this.element = append(container, $('code.version'));
this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.element, localize('extension version', "Extension Version")));
this._register(hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.element, localize('extension version', "Extension Version")));
this.render();
}
render(): void {
@ -255,6 +258,7 @@ export class ExtensionEditor extends EditorPane {
@IExplorerService private readonly explorerService: IExplorerService,
@IViewsService private readonly viewsService: IViewsService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService,
@IHoverService private readonly hoverService: IHoverService,
) {
super(ExtensionEditor.ID, group, telemetryService, themeService, storageService);
this.extensionReadme = null;
@ -284,11 +288,11 @@ export class ExtensionEditor extends EditorPane {
const details = append(header, $('.details'));
const title = append(details, $('.title'));
const name = append(title, $('span.name.clickable', { role: 'heading', tabIndex: 0 }));
this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), name, localize('name', "Extension name")));
const versionWidget = new VersionWidget(title);
this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), name, localize('name', "Extension name")));
const versionWidget = new VersionWidget(title, this.hoverService);
const preview = append(title, $('span.preview'));
this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), preview, localize('preview', "Preview")));
this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), preview, localize('preview', "Preview")));
preview.textContent = localize('preview', "Preview");
const builtin = append(title, $('span.builtin'));
@ -296,7 +300,7 @@ export class ExtensionEditor extends EditorPane {
const subtitle = append(details, $('.subtitle'));
const publisher = append(append(subtitle, $('.subtitle-entry')), $('.publisher.clickable', { tabIndex: 0 }));
this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), publisher, localize('publisher', "Publisher")));
this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), publisher, localize('publisher', "Publisher")));
publisher.setAttribute('role', 'button');
const publisherDisplayName = append(publisher, $('.publisher-name'));
const verifiedPublisherWidget = this.instantiationService.createInstance(VerifiedPublisherWidget, append(publisher, $('.verified-publisher')), false);
@ -305,11 +309,11 @@ export class ExtensionEditor extends EditorPane {
resource.setAttribute('role', 'button');
const installCount = append(append(subtitle, $('.subtitle-entry')), $('span.install', { tabIndex: 0 }));
this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), installCount, localize('install count', "Install count")));
this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), installCount, localize('install count', "Install count")));
const installCountWidget = this.instantiationService.createInstance(InstallCountWidget, installCount, false);
const rating = append(append(subtitle, $('.subtitle-entry')), $('span.rating.clickable', { tabIndex: 0 }));
this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), rating, localize('rating', "Rating")));
this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), rating, localize('rating', "Rating")));
rating.setAttribute('role', 'link'); // #132645
const ratingsWidget = this.instantiationService.createInstance(RatingsWidget, rating, false);
@ -549,14 +553,14 @@ export class ExtensionEditor extends EditorPane {
const workspaceFolder = this.contextService.getWorkspaceFolder(location);
if (workspaceFolder && extension.isWorkspaceScoped) {
template.resource.parentElement?.classList.add('clickable');
this.transientDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), template.resource, this.uriIdentityService.extUri.relativePath(workspaceFolder.uri, location)));
this.transientDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), template.resource, this.uriIdentityService.extUri.relativePath(workspaceFolder.uri, location)));
template.resource.textContent = localize('workspace extension', "Workspace Extension");
this.transientDisposables.add(onClick(template.resource, () => {
this.viewsService.openView(EXPLORER_VIEW_ID, true).then(() => this.explorerService.select(location, true));
}));
} else {
template.resource.parentElement?.classList.remove('clickable');
this.transientDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), template.resource, location.path));
this.transientDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), template.resource, location.path));
template.resource.textContent = localize('local extension', "Local Extension");
}
}
@ -965,7 +969,7 @@ export class ExtensionEditor extends EditorPane {
for (const [label, uri] of resources) {
const resource = append(resourcesElement, $('a.resource', { tabindex: '0' }, label));
this.transientDisposables.add(onClick(resource, () => this.openerService.open(uri)));
this.transientDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), resource, uri.toString()));
this.transientDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), resource, uri.toString()));
}
}
}

View file

@ -60,6 +60,7 @@ import { Extensions, IExtensionFeatureRenderer, IExtensionFeaturesManagementServ
import { URI } from 'vs/base/common/uri';
import { isString } from 'vs/base/common/types';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export const NONE_CATEGORY = 'none';
@ -135,6 +136,7 @@ export class ExtensionsListView extends ViewPane {
@IExtensionsWorkbenchService protected extensionsWorkbenchService: IExtensionsWorkbenchService,
@IExtensionRecommendationsService protected extensionRecommendationsService: IExtensionRecommendationsService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IConfigurationService configurationService: IConfigurationService,
@IWorkspaceContextService protected contextService: IWorkspaceContextService,
@IExtensionManagementServerService protected readonly extensionManagementServerService: IExtensionManagementServerService,
@ -158,7 +160,7 @@ export class ExtensionsListView extends ViewPane {
...(viewletViewOptions as IViewPaneOptions),
showActions: ViewPaneShowActions.Always,
maximumBodySize: options.flexibleHeight ? (storageService.getNumber(`${viewletViewOptions.id}.size`, StorageScope.PROFILE, 0) ? undefined : 0) : undefined
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
if (this.options.onDidChangeTitle) {
this._register(this.options.onDidChangeTitle(title => this.updateTitle(title)));
}
@ -1325,6 +1327,7 @@ export class StaticQueryExtensionsView extends ExtensionsListView {
@IExtensionsWorkbenchService extensionsWorkbenchService: IExtensionsWorkbenchService,
@IExtensionRecommendationsService extensionRecommendationsService: IExtensionRecommendationsService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IConfigurationService configurationService: IConfigurationService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IExtensionManagementServerService extensionManagementServerService: IExtensionManagementServerService,
@ -1345,7 +1348,7 @@ export class StaticQueryExtensionsView extends ExtensionsListView {
@ILogService logService: ILogService
) {
super(options, viewletViewOptions, notificationService, keybindingService, contextMenuService, instantiationService, themeService, extensionService,
extensionsWorkbenchService, extensionRecommendationsService, telemetryService, configurationService, contextService, extensionManagementServerService,
extensionsWorkbenchService, extensionRecommendationsService, telemetryService, hoverService, configurationService, contextService, extensionManagementServerService,
extensionManifestPropertiesService, extensionManagementService, workspaceService, productService, contextKeyService, viewDescriptorService, openerService,
preferencesService, storageService, workspaceTrustManagementService, extensionEnablementService, layoutService, extensionFeaturesManagementService,
uriIdentityService, logService);

View file

@ -31,7 +31,6 @@ import { URI } from 'vs/base/common/uri';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import Severity from 'vs/base/common/severity';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { Color } from 'vs/base/common/color';
import { renderMarkdown } from 'vs/base/browser/markdownRenderer';
import { IOpenerService } from 'vs/platform/opener/common/opener';
@ -43,6 +42,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { defaultCountBadgeStyles } from 'vs/platform/theme/browser/defaultStyles';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
export abstract class ExtensionWidget extends Disposable implements IExtensionContainer {
private _extension: IExtension | null = null;
@ -126,11 +126,12 @@ export class InstallCountWidget extends ExtensionWidget {
export class RatingsWidget extends ExtensionWidget {
private readonly containerHover: ICustomHover;
private readonly containerHover: IUpdatableHover;
constructor(
private container: HTMLElement,
private small: boolean
private small: boolean,
@IHoverService hoverService: IHoverService
) {
super();
container.classList.add('extension-ratings');
@ -139,7 +140,7 @@ export class RatingsWidget extends ExtensionWidget {
container.classList.add('small');
}
this.containerHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), container, ''));
this.containerHover = this._register(hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), container, ''));
this.render();
}
@ -191,15 +192,16 @@ export class RatingsWidget extends ExtensionWidget {
export class VerifiedPublisherWidget extends ExtensionWidget {
private disposables = this._register(new DisposableStore());
private readonly containerHover: ICustomHover;
private readonly containerHover: IUpdatableHover;
constructor(
private container: HTMLElement,
private small: boolean,
@IHoverService hoverService: IHoverService,
@IOpenerService private readonly openerService: IOpenerService,
) {
super();
this.containerHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), container, ''));
this.containerHover = this._register(hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), container, ''));
this.render();
}
@ -240,6 +242,7 @@ export class SponsorWidget extends ExtensionWidget {
constructor(
private container: HTMLElement,
@IHoverService private readonly hoverService: IHoverService,
@IOpenerService private readonly openerService: IOpenerService,
@ITelemetryService private readonly telemetryService: ITelemetryService,
) {
@ -255,7 +258,7 @@ export class SponsorWidget extends ExtensionWidget {
}
const sponsor = append(this.container, $('span.sponsor.clickable', { tabIndex: 0 }));
this.disposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), sponsor, this.extension?.publisherSponsorLink.toString() ?? ''));
this.disposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), sponsor, this.extension?.publisherSponsorLink.toString() ?? ''));
sponsor.setAttribute('role', 'link'); // #132645
const sponsorIconElement = renderIcon(sponsorIcon);
const label = $('span', undefined, localize('sponsor', "Sponsor"));
@ -383,17 +386,18 @@ export class RemoteBadgeWidget extends ExtensionWidget {
class RemoteBadge extends Disposable {
readonly element: HTMLElement;
readonly elementHover: ICustomHover;
readonly elementHover: IUpdatableHover;
constructor(
private readonly tooltip: boolean,
@IHoverService hoverService: IHoverService,
@ILabelService private readonly labelService: ILabelService,
@IThemeService private readonly themeService: IThemeService,
@IExtensionManagementServerService private readonly extensionManagementServerService: IExtensionManagementServerService
) {
super();
this.element = $('div.extension-badge.extension-remote-badge');
this.elementHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.element, ''));
this.elementHover = this._register(hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.element, ''));
this.render();
}
@ -459,6 +463,7 @@ export class SyncIgnoredWidget extends ExtensionWidget {
private readonly container: HTMLElement,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@IHoverService private readonly hoverService: IHoverService,
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService: IUserDataSyncEnablementService,
) {
super();
@ -473,7 +478,7 @@ export class SyncIgnoredWidget extends ExtensionWidget {
if (this.extension && this.extension.state === ExtensionState.Installed && this.userDataSyncEnablementService.isEnabled() && this.extensionsWorkbenchService.isExtensionIgnoredToSync(this.extension)) {
const element = append(this.container, $('span.extension-sync-ignored' + ThemeIcon.asCSSSelector(syncIgnoredIcon)));
this.disposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), element, localize('syncingore.label', "This extension is ignored during sync.")));
this.disposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), element, localize('syncingore.label', "This extension is ignored during sync.")));
element.classList.add(...ThemeIcon.asClassNameArray(syncIgnoredIcon));
}
}
@ -546,7 +551,7 @@ export class ExtensionHoverWidget extends ExtensionWidget {
render(): void {
this.hover.value = undefined;
if (this.extension) {
this.hover.value = setupCustomHover({
this.hover.value = this.hoverService.setupUpdatableHover({
delay: this.configurationService.getValue<number>('workbench.hover.delay'),
showHover: (options) => {
return this.hoverService.showHover({

View file

@ -31,6 +31,7 @@ import { Schemas } from 'vs/base/common/network';
import { joinPath } from 'vs/base/common/resources';
import { IExtensionFeaturesManagementService } from 'vs/workbench/services/extensionManagement/common/extensionFeatures';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export const IExtensionHostProfileService = createDecorator<IExtensionHostProfileService>('extensionHostProfileService');
export const CONTEXT_PROFILE_SESSION_STATE = new RawContextKey<string>('profileSessionState', 'none');
@ -81,8 +82,9 @@ export class RuntimeExtensionsEditor extends AbstractRuntimeExtensionsEditor {
@IClipboardService clipboardService: IClipboardService,
@IExtensionHostProfileService private readonly _extensionHostProfileService: IExtensionHostProfileService,
@IExtensionFeaturesManagementService extensionFeaturesManagementService: IExtensionFeaturesManagementService,
@IHoverService hoverService: IHoverService
) {
super(group, telemetryService, themeService, contextKeyService, extensionsWorkbenchService, extensionService, notificationService, contextMenuService, instantiationService, storageService, labelService, environmentService, clipboardService, extensionFeaturesManagementService);
super(group, telemetryService, themeService, contextKeyService, extensionsWorkbenchService, extensionService, notificationService, contextMenuService, instantiationService, storageService, labelService, environmentService, clipboardService, extensionFeaturesManagementService, hoverService);
this._profileInfo = this._extensionHostProfileService.lastProfile;
this._extensionsHostRecorded = CONTEXT_EXTENSION_HOST_PROFILE_RECORDED.bindTo(contextKeyService);
this._profileSessionState = CONTEXT_PROFILE_SESSION_STATE.bindTo(contextKeyService);

View file

@ -22,6 +22,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { isWeb } from 'vs/base/common/platform';
import { DragAndDropObserver, getWindow } from 'vs/base/browser/dom';
import { ILocalizedString } from 'vs/platform/action/common/action';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class EmptyView extends ViewPane {
@ -42,8 +43,9 @@ export class EmptyView extends ViewPane {
@IContextKeyService contextKeyService: IContextKeyService,
@IOpenerService openerService: IOpenerService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this._register(this.contextService.onDidChangeWorkbenchState(() => this.refreshTitle()));
this._register(this.labelService.onDidChangeFormatters(() => this.refreshTitle()));

View file

@ -56,6 +56,7 @@ import { EditorOpenSource } from 'vs/platform/editor/common/editor';
import { ResourceMap } from 'vs/base/common/map';
import { isInputElement } from 'vs/base/browser/ui/list/listWidget';
import { AbstractTreePart } from 'vs/base/browser/ui/tree/abstractTree';
import { IHoverService } from 'vs/platform/hover/browser/hover';
function hasExpandedRootChild(tree: WorkbenchCompressibleAsyncDataTree<ExplorerItem | ExplorerItem[], ExplorerItem, FuzzyScore>, treeInput: ExplorerItem[]): boolean {
@ -201,6 +202,7 @@ export class ExplorerView extends ViewPane implements IExplorerView {
@ILabelService private readonly labelService: ILabelService,
@IThemeService themeService: IWorkbenchThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IExplorerService private readonly explorerService: IExplorerService,
@IStorageService private readonly storageService: IStorageService,
@IClipboardService private clipboardService: IClipboardService,
@ -209,7 +211,7 @@ export class ExplorerView extends ViewPane implements IExplorerView {
@ICommandService private readonly commandService: ICommandService,
@IOpenerService openerService: IOpenerService
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.delegate = options.delegate;
this.resourceContext = instantiationService.createInstance(ResourceContextKey);

View file

@ -68,7 +68,7 @@ import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
import { mainWindow } from 'vs/base/browser/window';
import { IExplorerFileContribution, explorerFileContribRegistry } from 'vs/workbench/contrib/files/browser/explorerFileContrib';
import { IHoverWidget } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import type { IHoverWidget } from 'vs/base/browser/ui/hover/hover';
export class ExplorerDelegate implements IListVirtualDelegate<ExplorerItem> {

View file

@ -54,6 +54,7 @@ import { extUriIgnorePathCase } from 'vs/base/common/resources';
import { ILocalizedString } from 'vs/platform/action/common/action';
import { mainWindow } from 'vs/base/browser/window';
import { EditorGroupView } from 'vs/workbench/browser/parts/editor/editorGroupView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = dom.$;
@ -90,11 +91,12 @@ export class OpenEditorsView extends ViewPane {
@IContextKeyService contextKeyService: IContextKeyService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService,
@IOpenerService openerService: IOpenerService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.structuralRefreshDelay = 0;
this.sortOrder = configurationService.getValue('explorer.openEditors.sortOrder');

View file

@ -52,9 +52,9 @@ import { ICodeEditorWidgetOptions } from 'vs/editor/browser/widget/codeEditor/co
import { SnippetController2 } from 'vs/editor/contrib/snippet/browser/snippetController2';
import { SuggestController } from 'vs/editor/contrib/suggest/browser/suggestController';
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export interface InlineChatWidgetViewState {
@ -156,6 +156,7 @@ export class InlineChatWidget {
@IAccessibleViewService private readonly _accessibleViewService: IAccessibleViewService,
@ITextModelService protected readonly _textModelResolverService: ITextModelService,
@IChatService private readonly _chatService: IChatService,
@IHoverService private readonly _hoverService: IHoverService,
) {
// toolbars
this._progressBar = new ProgressBar(this._elements.progress);
@ -295,7 +296,7 @@ export class InlineChatWidget {
this._updateAriaLabel();
// this._elements.status
this._store.add(setupCustomHover(getDefaultHoverDelegate('element'), this._elements.statusLabel, () => {
this._store.add(this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('element'), this._elements.statusLabel, () => {
return this._elements.statusLabel.dataset['title'];
}));
@ -650,8 +651,9 @@ export class EditorBasedInlineChatWidget extends InlineChatWidget {
@IAccessibleViewService accessibleViewService: IAccessibleViewService,
@ITextModelService textModelResolverService: ITextModelService,
@IChatService chatService: IChatService,
@IHoverService hoverService: IHoverService,
) {
super(ChatAgentLocation.Editor, { ...options, editorOverflowWidgetsDomNode: _parentEditor.getOverflowWidgetsDomNode() }, instantiationService, contextKeyService, keybindingService, accessibilityService, configurationService, accessibleViewService, textModelResolverService, chatService);
super(ChatAgentLocation.Editor, { ...options, editorOverflowWidgetsDomNode: _parentEditor.getOverflowWidgetsDomNode() }, instantiationService, contextKeyService, keybindingService, accessibilityService, configurationService, accessibleViewService, textModelResolverService, chatService, hoverService);
// preview editors
this._previewDiffEditor = new Lazy(() => this._store.add(instantiationService.createInstance(EmbeddedDiffEditorWidget, this._elements.previewDiff, {

View file

@ -58,6 +58,8 @@ import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
import { ChatSlashCommandService, IChatSlashCommandService } from 'vs/workbench/contrib/chat/common/chatSlashCommands';
import { ChatWidgetService } from 'vs/workbench/contrib/chat/browser/chatWidget';
import { ChatWidgetHistoryService, IChatWidgetHistoryService } from 'vs/workbench/contrib/chat/common/chatWidgetHistoryService';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { NullHoverService } from 'vs/platform/hover/test/browser/nullHoverService';
suite('InteractiveChatController', function () {
class TestController extends InlineChatController {
@ -121,6 +123,7 @@ suite('InteractiveChatController', function () {
[IChatVariablesService, new MockChatVariablesService()],
[ILogService, new NullLogService()],
[ITelemetryService, NullTelemetryService],
[IHoverService, NullHoverService],
[IExtensionService, new TestExtensionService()],
[IContextKeyService, new MockContextKeyService()],
[IViewsService, new TestExtensionService()],

View file

@ -33,7 +33,7 @@ import { Categories } from 'vs/platform/action/common/actionCommonCategories';
import { IAccessibilityInformation } from 'vs/platform/accessibility/common/accessibility';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { nativeHoverDelegate } from 'vs/platform/hover/browser/hover';
import { IHoverService, nativeHoverDelegate } from 'vs/platform/hover/browser/hover';
class LanguageStatusViewModel {
@ -104,6 +104,7 @@ class LanguageStatus {
@ILanguageStatusService private readonly _languageStatusService: ILanguageStatusService,
@IStatusbarService private readonly _statusBarService: IStatusbarService,
@IEditorService private readonly _editorService: IEditorService,
@IHoverService private readonly _hoverService: IHoverService,
@IOpenerService private readonly _openerService: IOpenerService,
@IStorageService private readonly _storageService: IStorageService,
) {
@ -324,7 +325,7 @@ class LanguageStatus {
href: URI.from({
scheme: 'command', path: command.id, query: command.arguments && JSON.stringify(command.arguments)
}).toString()
}, { hoverDelegate: nativeHoverDelegate }, this._openerService));
}, { hoverDelegate: nativeHoverDelegate }, this._hoverService, this._openerService));
}
// -- pin
@ -374,7 +375,7 @@ class LanguageStatus {
const parts = renderLabelWithIcons(node);
dom.append(target, ...parts);
} else {
store.add(new Link(target, node, undefined, this._openerService));
store.add(new Link(target, node, undefined, this._hoverService, this._openerService));
}
}
}

View file

@ -30,6 +30,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { Range } from 'vs/editor/common/core/range';
import { unsupportedSchemas } from 'vs/platform/markers/common/markerService';
import Severity from 'vs/base/common/severity';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = DOM.$;
@ -118,6 +119,7 @@ class MarkerCodeColumnRenderer implements ITableRenderer<MarkerTableItem, IMarke
readonly templateId: string = MarkerCodeColumnRenderer.TEMPLATE_ID;
constructor(
@IHoverService private readonly hoverService: IHoverService,
@IOpenerService private readonly openerService: IOpenerService
) { }
@ -131,7 +133,7 @@ class MarkerCodeColumnRenderer implements ITableRenderer<MarkerTableItem, IMarke
const codeLabel = templateDisposable.add(new HighlightedLabel(codeColumn));
codeLabel.element.classList.add('code-label');
const codeLink = templateDisposable.add(new Link(codeColumn, { href: '', label: '' }, {}, this.openerService));
const codeLink = templateDisposable.add(new Link(codeColumn, { href: '', label: '' }, {}, this.hoverService, this.openerService));
return { codeColumn, sourceLabel, codeLabel, codeLink, templateDisposable };
}

View file

@ -51,8 +51,9 @@ import { MarkersContextKeys, MarkersViewMode } from 'vs/workbench/contrib/marker
import { unsupportedSchemas } from 'vs/platform/markers/common/markerService';
import { defaultCountBadgeStyles } from 'vs/platform/theme/browser/defaultStyles';
import Severity from 'vs/base/common/severity';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
interface IResourceMarkersTemplateData {
readonly resourceLabel: IResourceLabel;
@ -236,6 +237,7 @@ export class MarkerRenderer implements ITreeRenderer<Marker, MarkerFilterData, I
constructor(
private readonly markersViewState: MarkersViewModel,
@IHoverService protected hoverService: IHoverService,
@IInstantiationService protected instantiationService: IInstantiationService,
@IOpenerService protected openerService: IOpenerService,
) { }
@ -244,7 +246,7 @@ export class MarkerRenderer implements ITreeRenderer<Marker, MarkerFilterData, I
renderTemplate(container: HTMLElement): IMarkerTemplateData {
const data: IMarkerTemplateData = Object.create(null);
data.markerWidget = new MarkerWidget(container, this.markersViewState, this.openerService, this.instantiationService);
data.markerWidget = new MarkerWidget(container, this.markersViewState, this.hoverService, this.openerService, this.instantiationService);
return data;
}
@ -287,12 +289,13 @@ class MarkerWidget extends Disposable {
private readonly icon: HTMLElement;
private readonly iconContainer: HTMLElement;
private readonly messageAndDetailsContainer: HTMLElement;
private readonly messageAndDetailsContainerHover: ICustomHover;
private readonly messageAndDetailsContainerHover: IUpdatableHover;
private readonly disposables = this._register(new DisposableStore());
constructor(
private parent: HTMLElement,
private readonly markersViewModel: MarkersViewModel,
private readonly _hoverService: IHoverService,
private readonly _openerService: IOpenerService,
_instantiationService: IInstantiationService
) {
@ -307,7 +310,7 @@ class MarkerWidget extends Disposable {
this.iconContainer = dom.append(parent, dom.$(''));
this.icon = dom.append(this.iconContainer, dom.$(''));
this.messageAndDetailsContainer = dom.append(parent, dom.$('.marker-message-details-container'));
this.messageAndDetailsContainerHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.messageAndDetailsContainer, ''));
this.messageAndDetailsContainerHover = this._register(this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.messageAndDetailsContainer, ''));
}
render(element: Marker, filterData: MarkerFilterData | undefined): void {
@ -404,7 +407,7 @@ class MarkerWidget extends Disposable {
const container = dom.$('.marker-code');
const code = this.disposables.add(new HighlightedLabel(container));
const link = marker.code.target.toString(true);
this.disposables.add(new Link(parent, { href: link, label: container, title: link }, undefined, this._openerService));
this.disposables.add(new Link(parent, { href: link, label: container, title: link }, undefined, this._hoverService, this._openerService));
const codeMatches = filterData && filterData.codeMatches || [];
code.set(marker.code.value, codeMatches);
}

View file

@ -54,6 +54,7 @@ import { ITableContextMenuEvent, ITableEvent } from 'vs/base/browser/ui/table/ta
import { MarkersTable } from 'vs/workbench/contrib/markers/browser/markersTable';
import { Markers, MarkersContextKeys, MarkersViewMode } from 'vs/workbench/contrib/markers/common/markers';
import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands';
import { IHoverService } from 'vs/platform/hover/browser/hover';
function createResourceMarkersIterator(resourceMarkers: ResourceMarkers): Iterable<ITreeElement<MarkerElement>> {
return Iterable.map(resourceMarkers.markers, m => {
@ -138,6 +139,7 @@ export class MarkersView extends FilterViewPane implements IMarkersView {
@IStorageService storageService: IStorageService,
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@IHoverService hoverService: IHoverService,
) {
const memento = new Memento(Markers.MARKERS_VIEW_STORAGE_ID, storageService);
const panelState = memento.getMemento(StorageScope.WORKSPACE, StorageTarget.MACHINE);
@ -150,7 +152,7 @@ export class MarkersView extends FilterViewPane implements IMarkersView {
text: panelState['filter'] || '',
history: panelState['filterHistory'] || []
}
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
}, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.memento = memento;
this.panelState = panelState;

View file

@ -8,6 +8,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { EditorContributionInstantiation, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IProductService } from 'vs/platform/product/common/productService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
@ -26,6 +27,7 @@ export class EmptyCellEditorHintContribution extends EmptyTextEditorHintContribu
@IEditorGroupsService editorGroupsService: IEditorGroupsService,
@ICommandService commandService: ICommandService,
@IConfigurationService configurationService: IConfigurationService,
@IHoverService hoverService: IHoverService,
@IKeybindingService keybindingService: IKeybindingService,
@IInlineChatSessionService inlineChatSessionService: IInlineChatSessionService,
@IInlineChatService inlineChatService: IInlineChatService,
@ -37,6 +39,7 @@ export class EmptyCellEditorHintContribution extends EmptyTextEditorHintContribu
editorGroupsService,
commandService,
configurationService,
hoverService,
keybindingService,
inlineChatSessionService,
inlineChatService,

View file

@ -41,6 +41,7 @@ import { IToggleStyles } from 'vs/base/browser/ui/toggle/toggle';
import { Disposable } from 'vs/base/common/lifecycle';
import { NotebookSetting } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { IActionViewItemOptions } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const NLS_FIND_INPUT_LABEL = nls.localize('label.find', "Find");
const NLS_FIND_INPUT_PLACEHOLDER = nls.localize('placeholder.find', "Find");
@ -319,6 +320,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
@IConfigurationService protected readonly _configurationService: IConfigurationService,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IHoverService hoverService: IHoverService,
protected readonly _state: FindReplaceState<NotebookFindFilters> = new FindReplaceState<NotebookFindFilters>(),
protected readonly _notebookEditor: INotebookEditor,
) {
@ -358,7 +360,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
this._state.change({ isReplaceRevealed: this._isReplaceVisible }, false);
this._updateReplaceViewDisplay();
}
}));
}, hoverService));
this._toggleReplaceBtn.setEnabled(!isInteractiveWindow);
this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
this._domNode.appendChild(this._toggleReplaceBtn.domNode);
@ -441,7 +443,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
onTrigger: () => {
this.find(true);
}
}));
}, hoverService));
this.nextBtn = this._register(new SimpleButton({
label: NLS_NEXT_MATCH_BTN_LABEL,
@ -449,7 +451,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
onTrigger: () => {
this.find(false);
}
}));
}, hoverService));
const closeBtn = this._register(new SimpleButton({
label: NLS_CLOSE_BTN_LABEL,
@ -457,7 +459,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
onTrigger: () => {
this.hide();
}
}));
}, hoverService));
this._innerFindDomNode.appendChild(this._findInput.domNode);
this._innerFindDomNode.appendChild(this._matchesCount);
@ -518,7 +520,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
onTrigger: () => {
this.replaceOne();
}
}));
}, hoverService));
// Replace all button
this._replaceAllBtn = this._register(new SimpleButton({
@ -527,7 +529,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
onTrigger: () => {
this.replaceAll();
}
}));
}, hoverService));
this._innerReplaceDomNode.appendChild(this._replaceBtn.domNode);
this._innerReplaceDomNode.appendChild(this._replaceAllBtn.domNode);

View file

@ -16,10 +16,10 @@ import { MATCHES_LIMIT } from 'vs/editor/contrib/find/browser/findModel';
import { FindReplaceState } from 'vs/editor/contrib/find/browser/findState';
import { NLS_MATCHES_LOCATION, NLS_NO_RESULTS } from 'vs/editor/contrib/find/browser/findWidget';
import { localize } from 'vs/nls';
import { IMenuService } from 'vs/platform/actions/common/actions';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { NotebookFindFilters } from 'vs/workbench/contrib/notebook/browser/contrib/find/findFilters';
import { FindModel } from 'vs/workbench/contrib/notebook/browser/contrib/find/findModel';
@ -82,10 +82,10 @@ class NotebookFindWidget extends SimpleFindReplaceWidget implements INotebookEdi
@IContextKeyService contextKeyService: IContextKeyService,
@IConfigurationService configurationService: IConfigurationService,
@IContextMenuService contextMenuService: IContextMenuService,
@IMenuService menuService: IMenuService,
@IHoverService hoverService: IHoverService,
@IInstantiationService instantiationService: IInstantiationService,
) {
super(contextViewService, contextKeyService, configurationService, contextMenuService, instantiationService, new FindReplaceState<NotebookFindFilters>(), _notebookEditor);
super(contextViewService, contextKeyService, configurationService, contextMenuService, instantiationService, hoverService, new FindReplaceState<NotebookFindFilters>(), _notebookEditor);
this._findModel = new FindModel(this._notebookEditor, this._state, this._configurationService);
DOM.append(this._notebookEditor.getDomNode(), this.getDomNode());

View file

@ -10,6 +10,7 @@ import { ITreeNode, ITreeRenderer } from 'vs/base/browser/ui/tree/tree';
import { FuzzyScore } from 'vs/base/common/filters';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
import { renderExpressionValue } from 'vs/workbench/contrib/debug/browser/baseDebugView';
import { INotebookVariableElement } from 'vs/workbench/contrib/notebook/browser/contrib/notebookVariables/notebookVariablesDataSource';
@ -45,6 +46,11 @@ export class NotebookVariableRenderer implements ITreeRenderer<INotebookVariable
return NotebookVariableRenderer.ID;
}
constructor(
@IHoverService private readonly _hoverService: IHoverService
) {
}
renderTemplate(container: HTMLElement): IVariableTemplateData {
const expression = dom.append(container, $('.expression'));
const name = dom.append(expression, $('span.name'));
@ -64,7 +70,7 @@ export class NotebookVariableRenderer implements ITreeRenderer<INotebookVariable
colorize: true,
hover: data.elementDisposables,
maxValueLength: MAX_VALUE_RENDER_LENGTH_IN_VIEWLET
});
}, this._hoverService);
}
disposeElement(element: ITreeNode<INotebookVariableElement, FuzzyScore>, index: number, templateData: IVariableTemplateData, height: number | undefined): void {

View file

@ -15,6 +15,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
@ -63,9 +64,10 @@ export class NotebookVariablesView extends ViewPane {
@ICommandService protected commandService: ICommandService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IMenuService private readonly menuService: IMenuService
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this._register(this.editorService.onDidActiveEditorChange(this.handleActiveEditorChange.bind(this)));
this._register(this.notebookKernelService.onDidNotebookVariablesUpdate(this.handleVariablesChanged.bind(this)));
@ -86,7 +88,7 @@ export class NotebookVariablesView extends ViewPane {
'notebookVariablesTree',
container,
new NotebookVariablesDelegate(),
[new NotebookVariableRenderer()],
[new NotebookVariableRenderer(this.hoverService)],
this.dataSource,
{
accessibilityProvider: new NotebookVariableAccessibilityProvider(),

View file

@ -9,7 +9,6 @@ import { EventType as TouchEventType } from 'vs/base/browser/touch';
import { IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { IActionProvider } from 'vs/base/browser/ui/dropdown/dropdown';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { renderLabelWithIcons } from 'vs/base/browser/ui/iconLabel/iconLabels';
import { IAction } from 'vs/base/common/actions';
import { ThemeIcon } from 'vs/base/common/themables';
@ -18,6 +17,8 @@ import { MenuItemAction, SubmenuItemAction } from 'vs/platform/actions/common/ac
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class CodiconActionViewItem extends MenuEntryActionViewItem {
@ -48,7 +49,7 @@ export class ActionViewWithLabel extends MenuEntryActionViewItem {
}
export class UnifiedSubmenuActionView extends SubmenuEntryActionViewItem {
private _actionLabel?: HTMLAnchorElement;
private _hover?: ICustomHover;
private _hover?: IUpdatableHover;
private _primaryAction: IAction | undefined;
constructor(
@ -59,7 +60,8 @@ export class UnifiedSubmenuActionView extends SubmenuEntryActionViewItem {
readonly subActionViewItemProvider: IActionViewItemProvider | undefined,
@IKeybindingService _keybindingService: IKeybindingService,
@IContextMenuService _contextMenuService: IContextMenuService,
@IThemeService _themeService: IThemeService
@IThemeService _themeService: IThemeService,
@IHoverService private readonly _hoverService: IHoverService
) {
super(action, { ...options, hoverDelegate: options?.hoverDelegate ?? getDefaultHoverDelegate('element') }, _keybindingService, _contextMenuService, _themeService);
}
@ -71,7 +73,7 @@ export class UnifiedSubmenuActionView extends SubmenuEntryActionViewItem {
this._actionLabel = document.createElement('a');
container.appendChild(this._actionLabel);
this._hover = this._register(setupCustomHover(this.options.hoverDelegate ?? getDefaultHoverDelegate('element'), this._actionLabel, ''));
this._hover = this._register(this._hoverService.setupUpdatableHover(this.options.hoverDelegate ?? getDefaultHoverDelegate('element'), this._actionLabel, ''));
this.updateLabel();

View file

@ -27,11 +27,11 @@ import { CellContentPart } from 'vs/workbench/contrib/notebook/browser/view/cell
import { ClickTargetType, IClickTarget } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellWidgets';
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
import { CellStatusbarAlignment, INotebookCellStatusBarItem } from 'vs/workbench/contrib/notebook/common/notebookCommon';
import { ITooltipMarkdownString, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IHoverDelegate, IHoverDelegateOptions } from 'vs/base/browser/ui/hover/hoverDelegate';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { HoverPosition } from 'vs/base/browser/ui/hover/hoverWidget';
import type { IUpdatableHoverTooltipMarkdownString } from 'vs/base/browser/ui/hover/hover';
const $ = DOM.$;
@ -284,6 +284,7 @@ class CellStatusBarItem extends Disposable {
@ICommandService private readonly _commandService: ICommandService,
@INotificationService private readonly _notificationService: INotificationService,
@IThemeService private readonly _themeService: IThemeService,
@IHoverService private readonly _hoverService: IHoverService,
) {
super();
@ -326,8 +327,8 @@ class CellStatusBarItem extends Disposable {
this.container.setAttribute('role', role || '');
if (item.tooltip) {
const hoverContent = typeof item.tooltip === 'string' ? item.tooltip : { markdown: item.tooltip } as ITooltipMarkdownString;
this._itemDisposables.add(setupCustomHover(this._hoverDelegate, this.container, hoverContent));
const hoverContent = typeof item.tooltip === 'string' ? item.tooltip : { markdown: item.tooltip } as IUpdatableHoverTooltipMarkdownString;
this._itemDisposables.add(this._hoverService.setupUpdatableHover(this._hoverDelegate, this.container, hoverContent));
}
this.container.classList.toggle('cell-status-item-has-command', !!item.command);

View file

@ -36,6 +36,7 @@ import { AbstractTreeViewState, IAbstractTreeViewState, TreeFindMode } from 'vs/
import { URI } from 'vs/base/common/uri';
import { ctxAllCollapsed, ctxFilterOnType, ctxFollowsCursor, ctxSortMode, IOutlinePane, OutlineSortOrder } from 'vs/workbench/contrib/outline/browser/outline';
import { defaultProgressBarStyles } from 'vs/platform/theme/browser/defaultStyles';
import { IHoverService } from 'vs/platform/hover/browser/hover';
class OutlineTreeSorter<E> implements ITreeSorter<E> {
@ -94,8 +95,9 @@ export class OutlinePane extends ViewPane implements IOutlinePane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, _instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, _instantiationService, openerService, themeService, telemetryService, hoverService);
this._outlineViewState.restore(this._storageService);
this._disposables.add(this._outlineViewState);

View file

@ -34,6 +34,7 @@ import { ResourceContextKey } from 'vs/workbench/common/contextkeys';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { IEditorConfiguration } from 'vs/workbench/browser/parts/editor/textEditor';
import { computeEditorAriaLabel } from 'vs/workbench/browser/editor';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class OutputViewPane extends ViewPane {
@ -56,8 +57,9 @@ export class OutputViewPane extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.scrollLockContextKey = CONTEXT_OUTPUT_SCROLL_LOCK.bindTo(this.contextKeyService);
const editorInstantiationService = instantiationService.createChild(new ServiceCollection([IContextKeyService, this.scopedContextKeyService]));

View file

@ -58,9 +58,10 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
import { registerNavigableContainer } from 'vs/workbench/browser/actions/widgetNavigationCommands';
import { IActionViewItemOptions } from 'vs/base/browser/ui/actionbar/actionViewItems';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = DOM.$;
@ -902,7 +903,7 @@ class ActionsColumnRenderer implements ITableRenderer<IKeybindingItemEntry, IAct
interface ICommandColumnTemplateData {
commandColumn: HTMLElement;
commandColumnHover: ICustomHover;
commandColumnHover: IUpdatableHover;
commandLabelContainer: HTMLElement;
commandLabel: HighlightedLabel;
commandDefaultLabelContainer: HTMLElement;
@ -917,9 +918,14 @@ class CommandColumnRenderer implements ITableRenderer<IKeybindingItemEntry, ICom
readonly templateId: string = CommandColumnRenderer.TEMPLATE_ID;
constructor(
@IHoverService private readonly _hoverService: IHoverService
) {
}
renderTemplate(container: HTMLElement): ICommandColumnTemplateData {
const commandColumn = DOM.append(container, $('.command'));
const commandColumnHover = setupCustomHover(getDefaultHoverDelegate('mouse'), commandColumn, '');
const commandColumnHover = this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), commandColumn, '');
const commandLabelContainer = DOM.append(commandColumn, $('.command-label'));
const commandLabel = new HighlightedLabel(commandLabelContainer);
const commandDefaultLabelContainer = DOM.append(commandColumn, $('.command-default-label'));
@ -1005,7 +1011,7 @@ class KeybindingColumnRenderer implements ITableRenderer<IKeybindingItemEntry, I
interface ISourceColumnTemplateData {
sourceColumn: HTMLElement;
sourceColumnHover: ICustomHover;
sourceColumnHover: IUpdatableHover;
sourceLabel: HighlightedLabel;
extensionContainer: HTMLElement;
extensionLabel: HTMLAnchorElement;
@ -1035,11 +1041,12 @@ class SourceColumnRenderer implements ITableRenderer<IKeybindingItemEntry, ISour
constructor(
@IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
@IHoverService private readonly hoverService: IHoverService,
) { }
renderTemplate(container: HTMLElement): ISourceColumnTemplateData {
const sourceColumn = DOM.append(container, $('.source'));
const sourceColumnHover = setupCustomHover(getDefaultHoverDelegate('mouse'), sourceColumn, '');
const sourceColumnHover = this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), sourceColumn, '');
const sourceLabel = new HighlightedLabel(DOM.append(sourceColumn, $('.source-label')));
const extensionContainer = DOM.append(sourceColumn, $('.extension-container'));
const extensionLabel = DOM.append<HTMLAnchorElement>(extensionContainer, $('a.extension-label', { tabindex: 0 }));
@ -1147,6 +1154,7 @@ class WhenColumnRenderer implements ITableRenderer<IKeybindingItemEntry, IWhenCo
constructor(
private readonly keybindingsEditor: KeybindingsEditor,
@IHoverService private readonly hoverService: IHoverService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
) { }
@ -1205,7 +1213,7 @@ class WhenColumnRenderer implements ITableRenderer<IKeybindingItemEntry, IWhenCo
if (keybindingItemEntry.keybindingItem.when) {
templateData.whenLabel.set(keybindingItemEntry.keybindingItem.when, keybindingItemEntry.whenMatches, keybindingItemEntry.keybindingItem.when);
templateData.disposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), templateData.element, keybindingItemEntry.keybindingItem.when));
templateData.disposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), templateData.element, keybindingItemEntry.keybindingItem.when));
} else {
templateData.whenLabel.set('-');
}

View file

@ -34,8 +34,10 @@ import { isWorkspaceFolder, IWorkspaceContextService, IWorkspaceFolder, Workbenc
import { settingsEditIcon, settingsScopeDropDownIcon } from 'vs/workbench/contrib/preferences/browser/preferencesIcons';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { ILanguageService } from 'vs/editor/common/languages/language';
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import type { IUpdatableHover } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export class FolderSettingsActionViewItem extends BaseActionViewItem {
private _folder: IWorkspaceFolder | null;
@ -43,7 +45,7 @@ export class FolderSettingsActionViewItem extends BaseActionViewItem {
private container!: HTMLElement;
private anchorElement!: HTMLElement;
private anchorElementHover!: ICustomHover;
private anchorElementHover!: IUpdatableHover;
private labelElement!: HTMLElement;
private detailsElement!: HTMLElement;
private dropDownElement!: HTMLElement;
@ -52,6 +54,7 @@ export class FolderSettingsActionViewItem extends BaseActionViewItem {
action: IAction,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IHoverService private readonly hoverService: IHoverService,
) {
super(null, action);
const workspace = this.contextService.getWorkspace();
@ -90,7 +93,7 @@ export class FolderSettingsActionViewItem extends BaseActionViewItem {
'aria-haspopup': 'true',
'tabindex': '0'
}, this.labelElement, this.detailsElement, this.dropDownElement);
this.anchorElementHover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.anchorElement, ''));
this.anchorElementHover = this._register(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), this.anchorElement, ''));
this._register(DOM.addDisposableListener(this.anchorElement, DOM.EventType.MOUSE_DOWN, e => DOM.EventHelper.stop(e)));
this._register(DOM.addDisposableListener(this.anchorElement, DOM.EventType.CLICK, e => this.onClick(e)));
this._register(DOM.addDisposableListener(this.container, DOM.EventType.KEY_UP, e => this.onKeyUp(e)));

View file

@ -21,8 +21,8 @@ import { IUserDataSyncEnablementService } from 'vs/platform/userDataSync/common/
import { SettingsTreeSettingElement } from 'vs/workbench/contrib/preferences/browser/settingsTreeModels';
import { POLICY_SETTING_TAG } from 'vs/workbench/contrib/preferences/common/preferences';
import { IWorkbenchConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IHoverOptions, IHoverService } from 'vs/platform/hover/browser/hover';
import { IHoverWidget } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import type { IHoverOptions, IHoverWidget } from 'vs/base/browser/ui/hover/hover';
const $ = DOM.$;

View file

@ -69,8 +69,8 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { ISetting, ISettingsGroup, SettingValueType } from 'vs/workbench/services/preferences/common/preferences';
import { getInvalidTypeError } from 'vs/workbench/services/preferences/common/preferencesValidation';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = DOM.$;
@ -770,6 +770,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
@IExtensionsWorkbenchService protected readonly _extensionsWorkbenchService: IExtensionsWorkbenchService,
@IProductService protected readonly _productService: IProductService,
@ITelemetryService protected readonly _telemetryService: ITelemetryService,
@IHoverService protected readonly _hoverService: IHoverService,
) {
super();
@ -804,7 +805,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
const descriptionElement = DOM.append(container, $('.setting-item-description'));
const modifiedIndicatorElement = DOM.append(container, $('.setting-item-modified-indicator'));
toDispose.add(setupCustomHover(getDefaultHoverDelegate('mouse'), modifiedIndicatorElement, () => localize('modified', "The setting has been configured in the current scope.")));
toDispose.add(this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), modifiedIndicatorElement, () => localize('modified', "The setting has been configured in the current scope.")));
const valueElement = DOM.append(container, $('.setting-item-value'));
const controlElement = DOM.append(valueElement, $('div.setting-item-control'));
@ -891,7 +892,7 @@ export abstract class AbstractSettingRenderer extends Disposable implements ITre
const titleTooltip = setting.key + (element.isConfigured ? ' - Modified' : '');
template.categoryElement.textContent = element.displayCategory ? (element.displayCategory + ': ') : '';
template.elementDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), template.categoryElement, titleTooltip));
template.elementDisposables.add(this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), template.categoryElement, titleTooltip));
template.labelElement.text = element.displayLabel;
template.labelElement.title = titleTooltip;
@ -1834,7 +1835,7 @@ export class SettingBoolRenderer extends AbstractSettingRenderer implements ITre
const controlElement = DOM.append(descriptionAndValueElement, $('.setting-item-bool-control'));
const descriptionElement = DOM.append(descriptionAndValueElement, $('.setting-item-description'));
const modifiedIndicatorElement = DOM.append(container, $('.setting-item-modified-indicator'));
toDispose.add(setupCustomHover(getDefaultHoverDelegate('mouse'), modifiedIndicatorElement, localize('modified', "The setting has been configured in the current scope.")));
toDispose.add(this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), modifiedIndicatorElement, localize('modified', "The setting has been configured in the current scope.")));
const deprecationWarningElement = DOM.append(container, $('.setting-item-deprecation-message'));

View file

@ -27,8 +27,8 @@ import { ThemeIcon } from 'vs/base/common/themables';
import { settingsDiscardIcon, settingsEditIcon, settingsRemoveIcon } from 'vs/workbench/contrib/preferences/browser/preferencesIcons';
import { settingsSelectBackground, settingsSelectBorder, settingsSelectForeground, settingsSelectListBorder, settingsTextInputBackground, settingsTextInputBorder, settingsTextInputForeground } from 'vs/workbench/contrib/preferences/common/settingsEditorColorRegistry';
import { defaultButtonStyles, getInputBoxStyle, getSelectBoxStyles } from 'vs/platform/theme/browser/defaultStyles';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverService } from 'vs/platform/hover/browser/hover';
const $ = DOM.$;
@ -412,6 +412,15 @@ export class ListSettingWidget extends AbstractListSettingWidget<IListDataItem>
super.setValue(listData);
}
constructor(
container: HTMLElement,
@IThemeService themeService: IThemeService,
@IContextViewService contextViewService: IContextViewService,
@IHoverService protected readonly hoverService: IHoverService
) {
super(container, themeService, contextViewService);
}
protected getEmptyItem(): IListDataItem {
return {
value: {
@ -675,7 +684,7 @@ export class ListSettingWidget extends AbstractListSettingWidget<IListDataItem>
: localize('listSiblingHintLabel', "List item `{0}` with sibling `${1}`", value.data, sibling);
const { rowElement } = rowElementGroup;
this.listDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), rowElement, title));
this.listDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), rowElement, title));
rowElement.setAttribute('aria-label', title);
}
@ -735,7 +744,7 @@ export class ExcludeSettingWidget extends ListSettingWidget {
: localize('excludeSiblingHintLabel', "Exclude files matching `{0}`, only when a file matching `{1}` is present", value.data, sibling);
const { rowElement } = rowElementGroup;
this.listDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), rowElement, title));
this.listDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), rowElement, title));
rowElement.setAttribute('aria-label', title);
}
@ -765,7 +774,7 @@ export class IncludeSettingWidget extends ListSettingWidget {
: localize('includeSiblingHintLabel', "Include files matching `{0}`, only when a file matching `{1}` is present", value.data, sibling);
const { rowElement } = rowElementGroup;
this.listDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), rowElement, title));
this.listDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), rowElement, title));
rowElement.setAttribute('aria-label', title);
}
@ -841,6 +850,15 @@ export class ObjectSettingDropdownWidget extends AbstractListSettingWidget<IObje
private keySuggester: IObjectKeySuggester = () => undefined;
private valueSuggester: IObjectValueSuggester = () => undefined;
constructor(
container: HTMLElement,
@IThemeService themeService: IThemeService,
@IContextViewService contextViewService: IContextViewService,
@IHoverService private readonly hoverService: IHoverService,
) {
super(container, themeService, contextViewService);
}
override setValue(listData: IObjectDataItem[], options?: IObjectSetValueOptions): void {
this.showAddButton = options?.showAddButton ?? this.showAddButton;
this.keySuggester = options?.keySuggester ?? this.keySuggester;
@ -1163,10 +1181,10 @@ export class ObjectSettingDropdownWidget extends AbstractListSettingWidget<IObje
const accessibleDescription = localize('objectPairHintLabel', "The property `{0}` is set to `{1}`.", item.key.data, item.value.data);
const keyDescription = this.getEnumDescription(item.key) ?? item.keyDescription ?? accessibleDescription;
this.listDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), keyElement, keyDescription));
this.listDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), keyElement, keyDescription));
const valueDescription = this.getEnumDescription(item.value) ?? accessibleDescription;
this.listDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), valueElement!, valueDescription));
this.listDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), valueElement!, valueDescription));
rowElement.setAttribute('aria-label', accessibleDescription);
}
@ -1197,6 +1215,15 @@ interface IBoolObjectSetValueOptions {
export class ObjectSettingCheckboxWidget extends AbstractListSettingWidget<IObjectDataItem> {
private currentSettingKey: string = '';
constructor(
container: HTMLElement,
@IThemeService themeService: IThemeService,
@IContextViewService contextViewService: IContextViewService,
@IHoverService private readonly hoverService: IHoverService,
) {
super(container, themeService, contextViewService);
}
override setValue(listData: IObjectDataItem[], options?: IBoolObjectSetValueOptions): void {
if (isDefined(options) && options.settingKey !== this.currentSettingKey) {
this.model.setEditKey('none');
@ -1317,7 +1344,7 @@ export class ObjectSettingCheckboxWidget extends AbstractListSettingWidget<IObje
const title = item.keyDescription ?? accessibleDescription;
const { rowElement, keyElement, valueElement } = rowElementGroup;
this.listDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), keyElement, title));
this.listDisposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), keyElement, title));
valueElement!.setAttribute('aria-label', accessibleDescription);
rowElement.setAttribute('aria-label', accessibleDescription);
}

View file

@ -5,7 +5,6 @@
import * as DOM from 'vs/base/browser/dom';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { DefaultStyleController, IListAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
import { RenderIndentGuides } from 'vs/base/browser/ui/tree/abstractTree';
@ -15,6 +14,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import { localize } from 'vs/nls';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IHoverService } from 'vs/platform/hover/browser/hover';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IListService, IWorkbenchObjectTreeOptions, WorkbenchObjectTree } from 'vs/platform/list/browser/listService';
import { getListStyles } from 'vs/platform/theme/browser/defaultStyles';
@ -112,6 +112,9 @@ export class TOCRenderer implements ITreeRenderer<SettingsTreeGroupElement, neve
templateId = TOC_ENTRY_TEMPLATE_ID;
constructor(private readonly _hoverService: IHoverService) {
}
renderTemplate(container: HTMLElement): ITOCEntryTemplate {
return {
labelElement: DOM.append(container, $('.settings-toc-entry')),
@ -128,7 +131,7 @@ export class TOCRenderer implements ITreeRenderer<SettingsTreeGroupElement, neve
const label = element.label;
template.labelElement.textContent = label;
template.elementDisposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), template.labelElement, label));
template.elementDisposables.add(this._hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), template.labelElement, label));
if (count) {
template.countElement.textContent = ` (${count})`;
@ -208,6 +211,7 @@ export class TOCTree extends WorkbenchObjectTree<SettingsTreeGroupElement> {
@IContextKeyService contextKeyService: IContextKeyService,
@IListService listService: IListService,
@IConfigurationService configurationService: IConfigurationService,
@IHoverService hoverService: IHoverService,
@IInstantiationService instantiationService: IInstantiationService,
) {
// test open mode
@ -233,7 +237,7 @@ export class TOCTree extends WorkbenchObjectTree<SettingsTreeGroupElement> {
'SettingsTOC',
container,
new TOCTreeDelegate(),
[new TOCRenderer()],
[new TOCRenderer(hoverService)],
options,
instantiationService,
contextKeyService,

View file

@ -54,6 +54,7 @@ import { getVirtualWorkspaceLocation } from 'vs/platform/workspace/common/virtua
import { IWalkthroughsService } from 'vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService';
import { Schemas } from 'vs/base/common/network';
import { mainWindow } from 'vs/base/browser/window';
import { IHoverService } from 'vs/platform/hover/browser/hover';
interface IViewModel {
onDidChangeHelpInformation: Event<void>;
@ -460,10 +461,11 @@ class HelpPanel extends ViewPane {
@IWorkbenchEnvironmentService protected readonly environmentService: IWorkbenchEnvironmentService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@IWorkspaceContextService private readonly workspaceContextService: IWorkspaceContextService,
@IWalkthroughsService private readonly walkthroughsService: IWalkthroughsService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
}
protected override renderBody(container: HTMLElement): void {

View file

@ -57,6 +57,7 @@ import { Codicon } from 'vs/base/common/codicons';
import { defaultButtonStyles, defaultInputBoxStyles } from 'vs/platform/theme/browser/defaultStyles';
import { Attributes, CandidatePort, Tunnel, TunnelCloseReason, TunnelModel, TunnelSource, forwardedPortsViewEnabled, makeAddress, mapHasAddressLocalhostOrAllInterfaces, parseAddress } from 'vs/workbench/services/remote/common/tunnelModel';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverService } from 'vs/platform/hover/browser/hover';
export const openPreviewEnabledContext = new RawContextKey<boolean>('openPreviewEnabled', false);
@ -781,10 +782,11 @@ export class TunnelPanel extends ViewPane {
@IThemeService themeService: IThemeService,
@IRemoteExplorerService private readonly remoteExplorerService: IRemoteExplorerService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
@ITunnelService private readonly tunnelService: ITunnelService,
@IContextViewService private readonly contextViewService: IContextViewService,
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
this.tunnelTypeContext = TunnelTypeContextKey.bindTo(contextKeyService);
this.tunnelCloseableContext = TunnelCloseableContextKey.bindTo(contextKeyService);
this.tunnelPrivacyContext = TunnelPrivacyContextKey.bindTo(contextKeyService);

View file

@ -27,6 +27,7 @@ import { Orientation } from 'vs/base/browser/ui/sash/sash';
import { Iterable } from 'vs/base/common/iterator';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { MenuId } from 'vs/platform/actions/common/actions';
import { IHoverService } from 'vs/platform/hover/browser/hover';
class ListDelegate implements IListVirtualDelegate<ISCMRepository> {
@ -55,9 +56,10 @@ export class SCMRepositoriesViewPane extends ViewPane {
@IConfigurationService configurationService: IConfigurationService,
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService
) {
super({ ...options, titleMenuId: MenuId.SCMSourceControlTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super({ ...options, titleMenuId: MenuId.SCMSourceControlTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
}
protected override renderBody(container: HTMLElement): void {

View file

@ -107,9 +107,10 @@ import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { DropdownWithPrimaryActionViewItem } from 'vs/platform/actions/browser/dropdownWithPrimaryActionViewItem';
import { clamp } from 'vs/base/common/numbers';
import { ILogService } from 'vs/platform/log/common/log';
import { ICustomHover, ITooltipMarkdownString, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { MarkdownString } from 'vs/base/common/htmlContent';
import type { IUpdatableHover, IUpdatableHoverTooltipMarkdownString } from 'vs/base/browser/ui/hover/hover';
import { IHoverService } from 'vs/platform/hover/browser/hover';
// type SCMResourceTreeNode = IResourceNode<ISCMResource, ISCMResourceGroup>;
// type SCMHistoryItemChangeResourceTreeNode = IResourceNode<SCMHistoryItemChangeTreeElement, SCMHistoryItemTreeElement>;
@ -895,7 +896,7 @@ interface HistoryItemTemplate {
readonly iconContainer: HTMLElement;
readonly label: IconLabel;
readonly statsContainer: HTMLElement;
readonly statsCustomHover: ICustomHover;
readonly statsCustomHover: IUpdatableHover;
readonly filesLabel: HTMLElement;
readonly insertionsLabel: HTMLElement;
readonly deletionsLabel: HTMLElement;
@ -912,7 +913,9 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
constructor(
private actionRunner: IActionRunner,
private actionViewItemProvider: IActionViewItemProvider,
@ISCMViewService private scmViewService: ISCMViewService) { }
@IHoverService private hoverService: IHoverService,
@ISCMViewService private scmViewService: ISCMViewService
) { }
renderTemplate(container: HTMLElement): HistoryItemTemplate {
// hack
@ -933,7 +936,7 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
const insertionsLabel = append(statsContainer, $('.insertions-label'));
const deletionsLabel = append(statsContainer, $('.deletions-label'));
const statsCustomHover = setupCustomHover(getDefaultHoverDelegate('element'), statsContainer, '');
const statsCustomHover = this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('element'), statsContainer, '');
disposables.add(statsCustomHover);
return { iconContainer, label: iconLabel, actionBar, statsContainer, statsCustomHover, filesLabel, insertionsLabel, deletionsLabel, elementDisposables: new DisposableStore(), disposables };
@ -967,7 +970,7 @@ class HistoryItemRenderer implements ICompressibleTreeRenderer<SCMHistoryItemTre
throw new Error('Should never happen since node is incompressible');
}
private getTooltip(historyItem: SCMHistoryItemTreeElement): ITooltipMarkdownString {
private getTooltip(historyItem: SCMHistoryItemTreeElement): IUpdatableHoverTooltipMarkdownString {
const markdown = new MarkdownString('', { isTrusted: true, supportThemeIcons: true });
if (historyItem.author) {
@ -2834,8 +2837,9 @@ export class SCMViewPane extends ViewPane {
@IContextKeyService contextKeyService: IContextKeyService,
@IOpenerService openerService: IOpenerService,
@ITelemetryService telemetryService: ITelemetryService,
@IHoverService hoverService: IHoverService,
) {
super({ ...options, titleMenuId: MenuId.SCMTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
super({ ...options, titleMenuId: MenuId.SCMTitle }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService, hoverService);
// View mode and sort key
this._viewMode = this.getViewMode();

View file

@ -30,8 +30,8 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { defaultCountBadgeStyles } from 'vs/platform/theme/browser/defaultStyles';
import { SearchContext } from 'vs/workbench/contrib/search/common/constants';
import { setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
import { IHoverService } from 'vs/platform/hover/browser/hover';
interface IFolderMatchTemplate {
label: IResourceLabel;
@ -301,6 +301,7 @@ export class MatchRenderer extends Disposable implements ICompressibleTreeRender
@IConfigurationService private readonly configurationService: IConfigurationService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
@IHoverService private readonly hoverService: IHoverService
) {
super();
}
@ -364,7 +365,7 @@ export class MatchRenderer extends Disposable implements ICompressibleTreeRender
templateData.after.textContent = preview.after;
const title = (preview.fullBefore + (replace ? match.replaceString : preview.inside) + preview.after).trim().substr(0, 999);
templateData.disposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), templateData.parent, title));
templateData.disposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), templateData.parent, title));
SearchContext.IsEditableItemKey.bindTo(templateData.contextKeyService).set(!(match instanceof MatchInNotebook && match.isReadonly()));
@ -376,7 +377,7 @@ export class MatchRenderer extends Disposable implements ICompressibleTreeRender
templateData.lineNumber.classList.toggle('show', (numLines > 0) || showLineNumbers);
templateData.lineNumber.textContent = lineNumberStr + extraLinesStr;
templateData.disposables.add(setupCustomHover(getDefaultHoverDelegate('mouse'), templateData.lineNumber, this.getMatchTitle(match, showLineNumbers)));
templateData.disposables.add(this.hoverService.setupUpdatableHover(getDefaultHoverDelegate('mouse'), templateData.lineNumber, this.getMatchTitle(match, showLineNumbers)));
templateData.actions.context = <ISearchActionContext>{ viewer: this.searchView.getControl(), element: match };

Some files were not shown because too many files have changed in this diff Show more