From f2f2ec08908bdde149b3c7032c069aa67639116f Mon Sep 17 00:00:00 2001 From: matsushitas Date: Fri, 22 Feb 2019 18:39:34 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=90=E3=82=A4=E3=83=8A=E3=83=AA=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E5=BC=B7=E5=88=B6=E7=9A=84?= =?UTF-8?q?=E3=81=AB=E9=96=8B=E3=81=84=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8F?= =?UTF-8?q?=E3=81=A6=E3=82=82=E8=A6=8B=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extension.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index 1c45ae2..8b76060 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -34,19 +34,19 @@ ${data} subscriptions.push(vscode.workspace.registerTextDocumentContentProvider(myScheme, myProvider)); // register a command that opens a avro-document - subscriptions.push(vscode.commands.registerCommand('avro.preview', async () => { - if (!vscode.window.activeTextEditor) { + subscriptions.push(vscode.commands.registerCommand('avro.preview', async (fileUri) => { + if (typeof fileUri === 'undefined' || !(fileUri instanceof vscode.Uri)) { return; } - const avroUri = vscode.window.activeTextEditor.document.uri; - if (path.extname(avroUri.path) !== '.avro') { + if (path.extname(fileUri.path) !== '.avro') { return; } - const title = `Preview ${avroUri.path}`; - const viewerUri = vscode.Uri.parse(`avro:${title}?${avroUri.path}`); + const title = `Preview ${fileUri.path}`; + const viewerUri = vscode.Uri.parse(`avro:${title}?${fileUri.path}`); let doc = await vscode.workspace.openTextDocument(viewerUri); // calls back into the provider await vscode.window.showTextDocument(doc, { preview: false }); })); + } export function deactivate() {}