@@ -23,7 +23,12 @@ import {
23
23
IEditorIntegrationOptions ,
24
24
IFeatureLabIntegration
25
25
} from '../feature' ;
26
- import { IRootPosition , IVirtualPosition , is_equal } from '../positioning' ;
26
+ import {
27
+ IRootPosition ,
28
+ IVirtualPosition ,
29
+ ProtocolCoordinates ,
30
+ is_equal
31
+ } from '../positioning' ;
27
32
import { ILSPFeatureManager , PLUGIN_ID } from '../tokens' ;
28
33
import { getModifierState } from '../utils' ;
29
34
import { VirtualDocument } from '../virtual/document' ;
@@ -122,10 +127,12 @@ export class HoverCM extends CodeMirrorIntegration {
122
127
private virtual_position : IVirtualPosition ;
123
128
protected cache : ResponseCache ;
124
129
125
- private debounced_get_hover : Throttler < Promise < lsProtocol . Hover | undefined > > ;
130
+ private debounced_get_hover : Throttler <
131
+ Promise < lsProtocol . Hover | undefined | null >
132
+ > ;
126
133
private tooltip : FreeTooltip ;
127
134
private _previousHoverRequest : Promise <
128
- Promise < lsProtocol . Hover | undefined >
135
+ Promise < lsProtocol . Hover | undefined | null >
129
136
> | null = null ;
130
137
131
138
constructor ( options : IEditorIntegrationOptions ) {
@@ -154,13 +161,7 @@ export class HoverCM extends CodeMirrorIntegration {
154
161
return false ;
155
162
}
156
163
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 ) ;
164
165
} ) ;
165
166
if ( matching_items . length > 1 ) {
166
167
this . console . warn (
@@ -250,10 +251,13 @@ export class HoverCM extends CodeMirrorIntegration {
250
251
}
251
252
252
253
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
+ ) ;
257
261
}
258
262
259
263
afterChange ( change : IEditorChange , root_position : IRootPosition ) {
0 commit comments