@@ -72,12 +72,8 @@ export namespace DocsBrowser {
72
72
}
73
73
74
74
// registers the browser in VSCode infrastructure
75
- export function registerDocsBrowser ( alwaysOpenInHackage : boolean ) : Disposable {
76
- if ( alwaysOpenInHackage ) {
77
- return commands . registerCommand ( 'haskell.showDocumentation' , openDocumentationOnHackage ) ;
78
- } else {
79
- return commands . registerCommand ( 'haskell.showDocumentation' , showDocumentation ) ;
80
- }
75
+ export function registerDocsBrowser ( ) : Disposable {
76
+ return commands . registerCommand ( 'haskell.showDocumentation' , showDocumentation ) ;
81
77
}
82
78
83
79
async function openDocumentationOnHackage ( {
@@ -143,6 +139,8 @@ export namespace DocsBrowser {
143
139
}
144
140
145
141
function processLink ( ms : MarkdownString | MarkedString ) : string | MarkdownString {
142
+ const openDocsInHackage = workspace . getConfiguration ( 'haskell' ) . get ( 'openDocumentationInHackage' ) ;
143
+ const openSourceInHackage = workspace . getConfiguration ( 'haskell' ) . get ( 'openSourceInHackage' ) ;
146
144
function transform ( s : string ) : string {
147
145
return s . replace (
148
146
/ \[ ( .+ ) \] \( ( f i l e : .+ \/ d o c \/ (?: .* h t m l \/ l i b r a r i e s \/ ) ? ( [ ^ \/ ] + ) \/ (?: .* \/ ) ? ( .+ \. h t m l # ? .* ) ) \) / gi,
@@ -151,15 +149,25 @@ export namespace DocsBrowser {
151
149
if ( title == 'Documentation' ) {
152
150
hackageUri = `https://hackage.haskell.org/package/${ packageName } /docs/${ fileAndAnchor } ` ;
153
151
const encoded = encodeURIComponent ( JSON . stringify ( { title, localPath, hackageUri } ) ) ;
154
- const cmd = 'command:haskell.showDocumentation?' + encoded ;
152
+ let cmd : string ;
153
+ if ( openDocsInHackage ) {
154
+ cmd = 'command:haskell.openDocumentationOnHackage?' + encoded ;
155
+ } else {
156
+ cmd = 'commnad:haskell.showDocumentation?' + encoded ;
157
+ }
155
158
return `[${ title } ](${ cmd } )` ;
156
159
} else if ( title == 'Source' ) {
157
160
hackageUri = `https://hackage.haskell.org/package/${ packageName } /docs/src/${ fileAndAnchor . replace (
158
161
/ - / gi,
159
162
'.'
160
163
) } `;
161
164
const encoded = encodeURIComponent ( JSON . stringify ( { title, localPath, hackageUri } ) ) ;
162
- const cmd = 'command:haskell.showDocumentation?' + encoded ;
165
+ let cmd : string ;
166
+ if ( openSourceInHackage ) {
167
+ cmd = 'command:haskell.openDocumentationOnHackage?' + encoded ;
168
+ } else {
169
+ cmd = 'command:haskell.showDocumentation?' + encoded ;
170
+ }
163
171
return `[${ title } ](${ cmd } )` ;
164
172
} else {
165
173
return s ;
0 commit comments