Skip to content

Commit 05d03d7

Browse files
committed
Remove redundant awaits
1 parent 9247b44 commit 05d03d7

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

src/views/solution-outline/commands/open-command.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,22 @@ export class OpenCommand {
8484
);
8585
}
8686

87-
private async commandHandler(command: string, node: COutlineItem) {
87+
private commandHandler(command: string, node: COutlineItem): Promise<void> | undefined {
8888
const filePath = this.getFilePathForCommand(command, node);
8989
if (filePath) {
9090
const openExternal = command === OpenCommand.openDocCommandId;
91-
await this.openFile(filePath, openExternal);
91+
return this.openFile(filePath, openExternal);
9292
}
93+
94+
return undefined;
9395
}
9496

95-
private async openSourceFile(uri: vscode.Uri | undefined): Promise<void> {
97+
private openSourceFile(uri: vscode.Uri | undefined): Promise<void> | undefined {
9698
if (!uri) {
97-
return;
99+
return undefined;
98100
}
99101

100-
await this.openFile(uri.fsPath, false);
102+
return this.openFile(uri.fsPath, false);
101103
}
102104

103105
private getFilePathForCommand(command: string, node: COutlineItem): string | undefined {
@@ -112,13 +114,18 @@ export class OpenCommand {
112114
private async openFile(filePath: string, openExternal?: boolean): Promise<void> {
113115
if (openExternal) {
114116
this.openFileExternal.openFile(filePath);
115-
} else if (filePath.toLowerCase().endsWith('.md')) {
116-
await this.commandsProvider.executeCommand('markdown.showPreview', vscode.Uri.file(filePath));
117-
} else if (await this.shouldOpenConfigWizard(filePath)) {
118-
await this.commandsProvider.executeCommand('vscode.openWith', vscode.Uri.file(filePath), OpenCommand.configWizardViewType);
119-
} else {
120-
await this.commandsProvider.executeCommand('vscode.open', vscode.Uri.file(filePath));
117+
return;
118+
}
119+
120+
if (filePath.toLowerCase().endsWith('.md')) {
121+
return this.commandsProvider.executeCommand('markdown.showPreview', vscode.Uri.file(filePath));
122+
}
123+
124+
if (await this.shouldOpenConfigWizard(filePath)) {
125+
return this.commandsProvider.executeCommand('vscode.openWith', vscode.Uri.file(filePath), OpenCommand.configWizardViewType);
121126
}
127+
128+
return this.commandsProvider.executeCommand('vscode.open', vscode.Uri.file(filePath));
122129
}
123130

124131
private async shouldOpenConfigWizard(filePath: string): Promise<boolean> {

0 commit comments

Comments
 (0)