@@ -146,6 +146,9 @@ export class HelpPanel {
146146 viewer ||= config ( ) . get < string > ( 'session.viewers.viewColumn.helpPanel' ) ;
147147 const viewColumn = asViewColumn ( viewer ) ;
148148
149+ // get or create webview:
150+ const webview = this . getWebview ( preserveFocus , viewColumn ) ;
151+
149152 // make sure helpFile is not a promise:
150153 helpFile = await helpFile ;
151154
@@ -154,9 +157,6 @@ export class HelpPanel {
154157 // modify html
155158 helpFile = await this . pimpMyHelp ( helpFile , this . webviewStyleUri , this . webviewScriptUri ) ;
156159
157- // get or create webview:
158- const webview = this . getWebview ( preserveFocus , viewColumn ) ;
159-
160160 // actually show the help page
161161 webview . html = helpFile . html ;
162162
@@ -360,33 +360,34 @@ export class HelpPanel {
360360 // replace katex js/css urls with http://localhost:<port>/ origin
361361 // and remove others.
362362 const url = new URL ( helpFile . url ) ;
363- const externalUri = ( await vscode . env . asExternalUri ( vscode . Uri . parse ( url . origin ) ) ) . toString ( true ) ;
364363
365- $ ( 'link' ) . each ( ( i , e ) => {
366- const obj = $ ( e ) ;
364+ for ( const elem of $ ( 'link' ) ) {
365+ const obj = $ ( elem ) ;
367366 const linkUrl = obj . attr ( 'href' ) ;
368367 if ( linkUrl ) {
369368 if ( linkUrl . includes ( 'katex' ) ) {
370- const newUrl = new URL ( linkUrl , externalUri ) ;
371- obj . attr ( 'href' , newUrl . toString ( ) ) ;
369+ const newUrl = new URL ( linkUrl , url . origin ) ;
370+ const newUri = await vscode . env . asExternalUri ( vscode . Uri . parse ( newUrl . toString ( ) ) ) ;
371+ obj . attr ( 'href' , newUri . toString ( true ) ) ;
372372 } else {
373373 obj . remove ( ) ;
374374 }
375375 }
376- } ) ;
376+ }
377377
378- $ ( 'script' ) . each ( ( i , e ) => {
379- const obj = $ ( e ) ;
378+ for ( const elem of $ ( 'script' ) ) {
379+ const obj = $ ( elem ) ;
380380 const scriptUrl = obj . attr ( 'src' ) ;
381381 if ( scriptUrl ) {
382382 if ( scriptUrl . includes ( 'katex' ) ) {
383- const newUrl = new URL ( scriptUrl , externalUri ) ;
384- obj . attr ( 'src' , newUrl . toString ( ) ) ;
383+ const newUrl = new URL ( scriptUrl , url . origin ) ;
384+ const newUri = await vscode . env . asExternalUri ( vscode . Uri . parse ( newUrl . toString ( ) ) ) ;
385+ obj . attr ( 'src' , newUri . toString ( true ) ) ;
385386 } else {
386387 obj . remove ( ) ;
387388 }
388389 }
389- } ) ;
390+ }
390391 }
391392
392393 if ( styleUri ) {
0 commit comments