diff --git a/src/browser/MouseZoneManager.ts b/src/browser/MouseZoneManager.ts index d697c1334a..59b6b0f1d4 100644 --- a/src/browser/MouseZoneManager.ts +++ b/src/browser/MouseZoneManager.ts @@ -7,9 +7,7 @@ import { Disposable } from 'common/Lifecycle'; import { addDisposableDomListener } from 'browser/Lifecycle'; import { IMouseService, ISelectionService } from 'browser/services/Services'; import { IMouseZoneManager, IMouseZone } from 'browser/Types'; -import { IBufferService } from 'common/services/Services'; - -const HOVER_DURATION = 500; +import { IBufferService, IOptionsService } from 'common/services/Services'; /** * The MouseZoneManager allows components to register zones within the terminal @@ -37,7 +35,8 @@ export class MouseZoneManager extends Disposable implements IMouseZoneManager { private readonly _screenElement: HTMLElement, @IBufferService private readonly _bufferService: IBufferService, @IMouseService private readonly _mouseService: IMouseService, - @ISelectionService private readonly _selectionService: ISelectionService + @ISelectionService private readonly _selectionService: ISelectionService, + @IOptionsService private readonly _optionsService: IOptionsService ) { super(); @@ -151,7 +150,7 @@ export class MouseZoneManager extends Disposable implements IMouseZoneManager { } // Restart the tooltip timeout - this._tooltipTimeout = setTimeout(() => this._onTooltip(e), HOVER_DURATION); + this._tooltipTimeout = window.setTimeout(() => this._onTooltip(e), this._optionsService.options.linkTooltipHoverDuration); } private _onTooltip(e: MouseEvent): void { diff --git a/src/common/services/OptionsService.ts b/src/common/services/OptionsService.ts index 44a55d33da..614eee3a1f 100644 --- a/src/common/services/OptionsService.ts +++ b/src/common/services/OptionsService.ts @@ -31,6 +31,7 @@ export const DEFAULT_OPTIONS: ITerminalOptions = Object.freeze({ fontWeight: 'normal', fontWeightBold: 'bold', lineHeight: 1.0, + linkTooltipHoverDuration: 500, letterSpacing: 0, logLevel: 'info', scrollback: 1000, diff --git a/src/common/services/Services.ts b/src/common/services/Services.ts index fc9f9e203c..0f3ab374fb 100644 --- a/src/common/services/Services.ts +++ b/src/common/services/Services.ts @@ -262,6 +262,7 @@ export interface ITerminalOptions { fontWeightBold: FontWeight; letterSpacing: number; lineHeight: number; + linkTooltipHoverDuration: number; logLevel: LogLevel; macOptionIsMeta: boolean; macOptionClickForcesSelection: boolean; diff --git a/typings/xterm.d.ts b/typings/xterm.d.ts index 9445d07548..79379058ca 100644 --- a/typings/xterm.d.ts +++ b/typings/xterm.d.ts @@ -118,7 +118,7 @@ declare module 'xterm' { fontWeightBold?: FontWeight; /** - * The spacing in whole pixels between characters.. + * The spacing in whole pixels between characters. */ letterSpacing?: number; @@ -127,6 +127,13 @@ declare module 'xterm' { */ lineHeight?: number; + /** + * The duration in milliseconds before link tooltip events fire when + * hovering on a link. + * @deprecated This will be removed when the link matcher API is removed. + */ + linkTooltipHoverDuration?: number; + /** * What log level to use, this will log for all levels below and including * what is set: @@ -305,7 +312,8 @@ declare module 'xterm' { validationCallback?: (uri: string, callback: (isValid: boolean) => void) => void; /** - * A callback that fires when the mouse hovers over a link for a moment. + * A callback that fires when the mouse hovers over a link for a period of + * time (defined by {@link ITerminalOptions.linkTooltipHoverDuration}). */ tooltipCallback?: (event: MouseEvent, uri: string, location: IViewportRange) => boolean | void;