@@ -3,15 +3,15 @@ import {
3
3
CancellationToken ,
4
4
commands ,
5
5
Disposable ,
6
- Hover as VHover ,
6
+ Hover ,
7
7
MarkdownString ,
8
8
MarkedString ,
9
- Position as VPosition ,
9
+ Position ,
10
10
ProviderResult ,
11
11
TextDocument ,
12
12
Uri ,
13
13
ViewColumn ,
14
- window
14
+ window ,
15
15
} from 'vscode' ;
16
16
import { ProvideHoverSignature } from 'vscode-languageclient' ;
17
17
@@ -21,19 +21,18 @@ export namespace DocsBrowser {
21
21
// registers the browser in VSCode infrastructure
22
22
export function registerDocsBrowser ( ) : Disposable {
23
23
return commands . registerCommand ( 'haskell.showDocumentation' , ( { title, path } : { title : string ; path : string } ) => {
24
- const uri = Uri . parse ( path ) . with ( { scheme : 'vscode-resource' } ) ;
25
- const arr = uri . path . match ( / ( [ ^ \/ ] + ) \. [ ^ . ] + $ / ) ;
24
+ const arr = path . match ( / ( [ ^ \/ ] + ) \. [ ^ . ] + $ / ) ;
26
25
const ttl = arr !== null && arr . length === 2 ? arr [ 1 ] . replace ( / - / gi, '.' ) : title ;
27
- const documentationDirectory = dirname ( uri . path ) ;
26
+ const documentationDirectory = dirname ( path ) ;
28
27
let panel ;
29
28
try {
29
+ // Make sure to use Uri.parse here, as path will already have 'file:///' in it
30
30
panel = window . createWebviewPanel ( 'haskell.showDocumentationPanel' , ttl , ViewColumn . Two , {
31
- localResourceRoots : [ Uri . file ( documentationDirectory ) ] ,
32
- enableFindWidget : true
31
+ localResourceRoots : [ Uri . parse ( documentationDirectory ) ] ,
32
+ enableFindWidget : true ,
33
33
} ) ;
34
-
35
- // tslint:disable-next-line:max-line-length
36
- panel . webview . html = `<iframe src="${ uri } " frameBorder="0" style="background: white; width: 100%; height: 100%; position:absolute; left: 0; right: 0; bottom: 0; top: 0px;" />` ;
34
+ const uri = panel . webview . asWebviewUri ( Uri . parse ( path ) ) ;
35
+ panel . webview . html = `<iframe src="${ uri } " frameBorder = "0" style = "background: white; width: 100%; height: 100%; position:absolute; left: 0; right: 0; bottom: 0; top: 0px;" /> ` ;
37
36
} catch ( e ) {
38
37
window . showErrorMessage ( e ) ;
39
38
}
@@ -43,12 +42,12 @@ export namespace DocsBrowser {
43
42
44
43
export function hoverLinksMiddlewareHook (
45
44
document : TextDocument ,
46
- position : VPosition ,
45
+ position : Position ,
47
46
token : CancellationToken ,
48
47
next : ProvideHoverSignature
49
- ) : ProviderResult < VHover > {
48
+ ) : ProviderResult < Hover > {
50
49
const res = next ( document , position , token ) ;
51
- return Promise . resolve ( res ) . then ( r => {
50
+ return Promise . resolve ( res ) . then ( ( r ) => {
52
51
if ( r !== null && r !== undefined ) {
53
52
r . contents = r . contents . map ( processLink ) ;
54
53
}
@@ -68,7 +67,7 @@ export namespace DocsBrowser {
68
67
const mstr = new MarkdownString ( transform ( ms ) ) ;
69
68
mstr . isTrusted = true ;
70
69
return mstr ;
71
- } else if ( typeof ms === 'object' ) {
70
+ } else if ( ms instanceof MarkdownString ) {
72
71
const mstr = new MarkdownString ( transform ( ms . value ) ) ;
73
72
mstr . isTrusted = true ;
74
73
return mstr ;
0 commit comments