From 50fd7cfefbe94a863cb11e1f4b0f295affab363f Mon Sep 17 00:00:00 2001 From: James Yu Date: Tue, 24 Sep 2024 16:40:47 +0800 Subject: [PATCH] Ditto --- src/extras/snippet-view.ts | 5 +---- test/units/09_viewer_server.test.ts | 2 +- test/units/10_viewer_pdf_server.test.ts | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/extras/snippet-view.ts b/src/extras/snippet-view.ts index 335b381d5..2bb8cf929 100644 --- a/src/extras/snippet-view.ts +++ b/src/extras/snippet-view.ts @@ -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((resolve) => { const rendered = (e: SnippetViewResult) => { if (e.type !== 'png') { @@ -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) { diff --git a/test/units/09_viewer_server.test.ts b/test/units/09_viewer_server.test.ts index ced5add0c..43cb99aa5 100644 --- a/test/units/09_viewer_server.test.ts +++ b/test/units/09_viewer_server.test.ts @@ -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 } diff --git a/test/units/10_viewer_pdf_server.test.ts b/test/units/10_viewer_pdf_server.test.ts index d80975369..32f0534b5 100644 --- a/test/units/10_viewer_pdf_server.test.ts +++ b/test/units/10_viewer_pdf_server.test.ts @@ -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 } @@ -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) }) })