Skip to content

Commit

Permalink
Merge pull request #3 from romiogaku/feature/needles-open-binary
Browse files Browse the repository at this point in the history
avroファイルをアクティブなエディタで開いてない状態でもプレビューが開けるようにした
  • Loading branch information
romiogaku authored Feb 22, 2019
2 parents f76a7dd + f2f2ec0 commit 3f6a3ba
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

0 comments on commit 3f6a3ba

Please sign in to comment.