Skip to content

Commit

Permalink
code: Use vscode.env.asExternalUri to generate preview uris
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Sep 29, 2024
1 parent c89ec6b commit 971fb91
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions code/changes/896.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The preview window should now work when using Codespaces
16 changes: 15 additions & 1 deletion code/src/node/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,21 @@ export class PreviewManager {
return
}

this.panel.webview.postMessage({ 'show': params.uri })
let panel = this.panel
let uri = vscode.Uri.parse(params.uri)

// Needed so that previews work in Codespaces
// see: https://github.com/swyddfa/esbonio/issues/896
vscode.env.asExternalUri(uri).then(
extUri => {
this.logger.debug(`${uri.toString(true)} -> asExternalUri -> ${extUri.toString(true)}`)
panel.webview.postMessage({ 'show': extUri.toString(true) })
},
err => {
this.logger.error(`Unable to convert uri to an external uri: ${err}`)
}
)

}

private showInternalDocument(params: ShowDocumentParams) {
Expand Down

0 comments on commit 971fb91

Please sign in to comment.