Skip to content

Commit

Permalink
fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyutkarsh committed Oct 21, 2019
1 parent 47ee410 commit 31ecc51
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function activate(context: vscode.ExtensionContext) {
vscode.window.showWarningMessage("Please right click on a VSIX file in the Explorer and select 'Show in VSIX Viewer'.");
return;
}
TelemetryClient.instance.sendEvent("showInVSIXViewer");
TelemetryClient.instance.sendEvent("showInVSIXViewerClicked");
const vsixOutlineProvider = new VsixOutlineProvider(context, selectedFile.fsPath);
vscode.window.registerTreeDataProvider("vsixViewer", vsixOutlineProvider);

Expand Down
6 changes: 4 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export default class Util {
return Util._instance;
}

public log(message: string) {
this._channel.appendLine(message);
public log(message: string | undefined) {
if (message) {
this._channel.appendLine(message);
}
}
}
16 changes: 11 additions & 5 deletions src/vsixOutlineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@ export class VsixOutlineProvider implements vscode.TreeDataProvider<VsixItem> {

async getChildren(element?: VsixItem): Promise<VsixItem[]> {
if (!element) {
Util.instance.log("Getting contents of VSIX");
let root = await this.parseVsix(this._vsixPath);
this.sort(root);
return Promise.resolve([root]);
try {
Util.instance.log("Getting contents of VSIX");
let root = await this.parseVsix(this._vsixPath);
this.sort(root);
return Promise.resolve([root]);
} catch (error) {
vscode.window.showErrorMessage(`An error ocurred while parsing VSIX: ${error}`);
return Promise.resolve([]);
}
}
else {
return Promise.resolve(element.children);
Expand Down Expand Up @@ -122,9 +127,10 @@ export class VsixOutlineProvider implements vscode.TreeDataProvider<VsixItem> {
fs.readFile(this._vsixPath, function (err, data) {
if (err) {
Util.instance.log("Error occurred while reading VSIX");
Util.instance.log(err.message);
Util.instance.log(err.stack);
TelemetryClient.instance.sendError(err);
reject(err);
return;
}
jszip.loadAsync(data, {
createFolders: true
Expand Down

0 comments on commit 31ecc51

Please sign in to comment.