Skip to content

Commit

Permalink
Ditto
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Sep 24, 2024
1 parent 7fb90f6 commit 50fd7cf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/extras/snippet-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ async function render(pdfFileUri: vscode.Uri, opts: { height: number, width: num
return
}
const uri = state.view.webview.asWebviewUri(pdfFileUri).toString()
let disposable: { dispose: () => void } | undefined
const promise = new Promise<RenderResult | undefined>((resolve) => {
const rendered = (e: SnippetViewResult) => {
if (e.type !== 'png') {
Expand All @@ -49,9 +48,7 @@ async function render(pdfFileUri: vscode.Uri, opts: { height: number, width: num
try {
const renderResult = await promise
return renderResult?.data
} finally {
disposable?.dispose()
}
} catch (_) { }
}

function receive(message: SnippetViewResult) {
Expand Down
2 changes: 1 addition & 1 deletion test/units/09_viewer_server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe(path.basename(__filename).split('.')[0] + ':', () => {
while (true) {
if (
handlerStub.called &&
(JSON.parse((handlerStub.lastCall.args?.[1] as unknown as Uint8Array).toString()) as ClientRequest).type === 'ping'
(JSON.parse((handlerStub.lastCall?.args?.[1] as Uint8Array).toString()) as ClientRequest).type === 'ping'
) {
break
}
Expand Down
4 changes: 2 additions & 2 deletions test/units/10_viewer_pdf_server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe(path.basename(__filename).split('.')[0] + ':', () => {
while (true) {
if (
handlerSpy.called &&
(JSON.parse((handlerSpy.lastCall.args?.[1] as unknown as Uint8Array).toString()) as ClientRequest).type === type
(JSON.parse((handlerSpy.lastCall?.args?.[1] as Uint8Array).toString()) as ClientRequest).type === type
) {
break
}
Expand Down Expand Up @@ -207,7 +207,7 @@ describe(path.basename(__filename).split('.')[0] + ':', () => {
stub.restore()

assert.strictEqual(stub.callCount, 1)
assert.strictEqual((stub.firstCall.args?.[0] as unknown as vscode.InputBoxOptions).value, (await lw.server.getUrl(pdfUri)).url)
assert.strictEqual((stub.firstCall?.args?.[0] as vscode.InputBoxOptions).value, (await lw.server.getUrl(pdfUri)).url)
})
})

Expand Down

0 comments on commit 50fd7cf

Please sign in to comment.