1
1
import { combineLatest , from , Observable } from 'rxjs'
2
- import { map , switchMap } from 'rxjs/operators'
2
+ import { catchError , map , switchMap } from 'rxjs/operators'
3
3
import { HoverMerged } from '../../client/types/hover'
4
4
import { TextDocumentPositionParams , TextDocumentRegistrationOptions } from '../../protocol'
5
5
import { Hover } from '../../protocol/plainTypes'
@@ -14,14 +14,20 @@ export class TextDocumentHoverProviderRegistry extends FeatureProviderRegistry<
14
14
TextDocumentRegistrationOptions ,
15
15
ProvideTextDocumentHoverSignature
16
16
> {
17
+ /**
18
+ * Returns an observable that emits all providers' hovers whenever any of the last-emitted set of providers emits
19
+ * hovers. If any provider emits an error, the error is logged and the provider is omitted from the emission of
20
+ * the observable (the observable does not emit the error).
21
+ */
17
22
public getHover ( params : TextDocumentPositionParams ) : Observable < HoverMerged | null > {
18
23
return getHover ( this . providers , params )
19
24
}
20
25
}
21
26
22
27
/**
23
28
* Returns an observable that emits all providers' hovers whenever any of the last-emitted set of providers emits
24
- * hovers.
29
+ * hovers. If any provider emits an error, the error is logged and the provider is omitted from the emission of
30
+ * the observable (the observable does not emit the error).
25
31
*
26
32
* Most callers should use TextDocumentHoverProviderRegistry's getHover method, which uses the registered hover
27
33
* providers.
@@ -36,7 +42,18 @@ export function getHover(
36
42
if ( providers . length === 0 ) {
37
43
return [ [ null ] ]
38
44
}
39
- return combineLatest ( providers . map ( provider => from ( provider ( params ) ) ) )
45
+ return combineLatest (
46
+ providers . map ( provider =>
47
+ from (
48
+ provider ( params ) . pipe (
49
+ catchError ( err => {
50
+ console . error ( err )
51
+ return [ null ]
52
+ } )
53
+ )
54
+ )
55
+ )
56
+ )
40
57
} )
41
58
)
42
59
. pipe ( map ( HoverMerged . from ) )
0 commit comments