Skip to content

Commit 31b29d4

Browse files
committed
Fix regression and add support for run setting commands for no workspaces
Fixes #137
1 parent b6d9735 commit 31b29d4

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

src/extension/utils/vscode.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -733,39 +733,40 @@ export function showCreateRunSettingsErrorWindow(message: string): void {
733733
});
734734
}
735735

736-
export function showOpenRunSettingsErrorWindow(message: string, file?: string): void {
736+
export async function showOpenRunSettingsErrorWindow(
737+
message: string,
738+
file?: string
739+
): Promise<void> {
737740
const items: string[] = [];
738741
if (file) {
739742
items.push("Fix Settings");
740743
}
741744
items.push("Open Run Settings", "Close");
742745

743-
vscode.window.showErrorMessage(message, ...items).then((choice) => {
744-
if (choice === "Open Run Settings") {
745-
vscode.commands.executeCommand("fastolympiccoding.openRunSettings");
746-
} else if (choice === "Fix Settings" && file) {
747-
const extension = path.extname(file);
748-
const workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(file));
749-
vscode.commands.executeCommand("fastolympiccoding.createRunSettings", {
750-
extension,
751-
workspaceFolder,
752-
});
753-
}
754-
});
746+
const choice = await vscode.window.showErrorMessage(message, ...items);
747+
if (choice === "Open Run Settings") {
748+
vscode.commands.executeCommand("fastolympiccoding.openRunSettings");
749+
} else if (choice === "Fix Settings" && file) {
750+
const extension = path.extname(file);
751+
const workspaceFolder = await getFileWorkspace(file);
752+
vscode.commands.executeCommand("fastolympiccoding.createRunSettings", {
753+
extension,
754+
workspaceFolder,
755+
});
756+
}
755757
}
756758

757-
export function showAddLanguageSettingsError(
759+
export async function showAddLanguageSettingsError(
758760
message: string,
759761
extension: string,
760762
file: string
761-
): void {
762-
vscode.window.showErrorMessage(message, "Add Language Settings", "Close").then((choice) => {
763-
if (choice === "Add Language Settings") {
764-
const workspaceFolder = vscode.workspace.getWorkspaceFolder(vscode.Uri.file(file));
765-
vscode.commands.executeCommand("fastolympiccoding.createRunSettings", {
766-
extension,
767-
workspaceFolder,
768-
});
769-
}
770-
});
763+
): Promise<void> {
764+
const choice = await vscode.window.showErrorMessage(message, "Add Language Settings", "Close");
765+
if (choice === "Add Language Settings") {
766+
const workspaceFolder = await getFileWorkspace(file);
767+
vscode.commands.executeCommand("fastolympiccoding.createRunSettings", {
768+
extension,
769+
workspaceFolder,
770+
});
771+
}
771772
}

0 commit comments

Comments
 (0)