From 6feb87f663d0bd9e1256f8ec3c850aee1a3456de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Garc=C3=ADa=20Sainz-Aja?= Date: Mon, 19 Dec 2022 15:34:31 +0100 Subject: [PATCH] fix: return one single file when prompting for AsyncAPI files #146 (#150) --- src/PreviewWebPanel.ts | 3 ++- src/extension.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/PreviewWebPanel.ts b/src/PreviewWebPanel.ts index 9e7ec61..fe40b13 100644 --- a/src/PreviewWebPanel.ts +++ b/src/PreviewWebPanel.ts @@ -62,7 +62,7 @@ async function promptForAsyncapiFile() { if (isAsyncAPIFile(vscode.window.activeTextEditor?.document)) { return vscode.window.activeTextEditor?.document.uri; } - return await vscode.window.showOpenDialog({ + const uris = await vscode.window.showOpenDialog({ canSelectFiles: true, canSelectFolders: false, canSelectMany: false, @@ -71,6 +71,7 @@ async function promptForAsyncapiFile() { AsyncAPI: ['yml', 'yaml', 'json'], }, }); + return uris?.[0]; } function getWebviewContent(context: vscode.ExtensionContext, webview: vscode.Webview, asyncapiFile: vscode.Uri) { diff --git a/src/extension.ts b/src/extension.ts index 3aab485..55cfbfb 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -28,6 +28,9 @@ export function activate(context: vscode.ExtensionContext) { console.log('Reloading asyncapi file', document.uri.fsPath); openAsyncAPI(context, document.uri); } + if (vscode.window.activeTextEditor?.document) { + setAsyncAPIPreviewContext(vscode.window.activeTextEditor.document); + } });