@@ -23,7 +23,12 @@ import {
2323 IEditorIntegrationOptions ,
2424 IFeatureLabIntegration
2525} from '../feature' ;
26- import { IRootPosition , IVirtualPosition , is_equal } from '../positioning' ;
26+ import {
27+ IRootPosition ,
28+ IVirtualPosition ,
29+ ProtocolCoordinates ,
30+ is_equal
31+ } from '../positioning' ;
2732import { ILSPFeatureManager , PLUGIN_ID } from '../tokens' ;
2833import { getModifierState } from '../utils' ;
2934import { VirtualDocument } from '../virtual/document' ;
@@ -122,10 +127,12 @@ export class HoverCM extends CodeMirrorIntegration {
122127 private virtual_position : IVirtualPosition ;
123128 protected cache : ResponseCache ;
124129
125- private debounced_get_hover : Throttler < Promise < lsProtocol . Hover | undefined > > ;
130+ private debounced_get_hover : Throttler <
131+ Promise < lsProtocol . Hover | undefined | null >
132+ > ;
126133 private tooltip : FreeTooltip ;
127134 private _previousHoverRequest : Promise <
128- Promise < lsProtocol . Hover | undefined >
135+ Promise < lsProtocol . Hover | undefined | null >
129136 > | null = null ;
130137
131138 constructor ( options : IEditorIntegrationOptions ) {
@@ -154,13 +161,7 @@ export class HoverCM extends CodeMirrorIntegration {
154161 return false ;
155162 }
156163 let range = cache_item . response . range ! ;
157- return (
158- line >= range . start . line &&
159- line <= range . end . line &&
160- // need to be non-overlapping see https://github.com/jupyter-lsp/jupyterlab-lsp/issues/628
161- ( line != range . start . line || ch > range . start . character ) &&
162- ( line != range . end . line || ch <= range . end . character )
163- ) ;
164+ return ProtocolCoordinates . isWithinRange ( { line, character : ch } , range ) ;
164165 } ) ;
165166 if ( matching_items . length > 1 ) {
166167 this . console . warn (
@@ -250,10 +251,13 @@ export class HoverCM extends CodeMirrorIntegration {
250251 }
251252
252253 protected create_throttler ( ) {
253- return new Throttler < Promise < lsProtocol . Hover | undefined > > ( this . on_hover , {
254- limit : this . settings . composite . throttlerDelay ,
255- edge : 'trailing'
256- } ) ;
254+ return new Throttler < Promise < lsProtocol . Hover | undefined | null > > (
255+ this . on_hover ,
256+ {
257+ limit : this . settings . composite . throttlerDelay ,
258+ edge : 'trailing'
259+ }
260+ ) ;
257261 }
258262
259263 afterChange ( change : IEditorChange , root_position : IRootPosition ) {
0 commit comments