hoverTooltip

Show a hover tooltip when the user points at text matching source.

Parameters

source

Function that, given a session and position, returns a tooltip or null.


fun hoverTooltip(hoverTime: Long, source: suspend (EditorSession, Int) -> Tooltip?): Extension

Show a hover tooltip computed by a suspending source.

This is the asynchronous counterpart to the synchronous hoverTooltip: where the synchronous overload demands a tooltip be produced immediately, this one lets source suspend — for example to issue a network/IPC request such as an LSP textDocument/hover — before returning a Tooltip (or null for "no tooltip here").

Upstream CodeMirror's hover source is promise-based ((view, pos, side) => Tooltip | Promise<Tooltip | null> | null); kodemirror's synchronous overload cannot express that, so this overload is the Kotlin/coroutine adaptation of upstream's async hover path.

Behavior matches upstream's hover machinery:

  • The request is debounced by hoverTime (the pointer must rest for that long before source is invoked).

  • Moving to a different position cancels any in-flight request, so a slow server response for an abandoned position never pops a stale tooltip.

Parameters

hoverTime

Delay before source is invoked, in milliseconds. Pass DEFAULT_HOVER_TIME for upstream's default; an explicit value is required so a bare trailing lambda is not ambiguous with the synchronous hoverTooltip overload.

source

Suspending function returning a tooltip for the position, or null.