Skip to content

Commit

Permalink
feat: improve notification message when configuring several tools
Browse files Browse the repository at this point in the history
  • Loading branch information
hverlin committed Nov 19, 2024
1 parent 2171427 commit 0c10571
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 31 deletions.
77 changes: 61 additions & 16 deletions src/providers/toolsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,11 +513,30 @@ export function registerToolsCommands(
useSymLinks: vscode.workspace
.getConfiguration("mise")
.get("configureExtensionsUseSymLinks"),
}).catch((error) => {
logger.error(
`Failed to configure the extension ${configurableTool.extensionName} for ${selectedTool.name}: ${error}`,
);
});
})
.then(({ configurableExtension, updatedKeys }) => {
if (updatedKeys.length === 0) {
return;
}

vscode.window
.showInformationMessage(
`Mise: Extension ${configurableExtension.extensionName} configured.\n(updated: ${updatedKeys.join("\n")})`,
"Show settings",
)
.then((selection) => {
if (selection === "Show settings") {
vscode.commands.executeCommand(
"workbench.action.openWorkspaceSettingsFile",
);
}
});
})
.catch((error) => {
logger.error(
`Failed to configure the extension ${configurableTool.extensionName} for ${selectedTool.name}: ${error}`,
);
});
},
),
vscode.commands.registerCommand("mise.configureAllSdkPaths", async () => {
Expand Down Expand Up @@ -550,6 +569,7 @@ export function registerToolsCommands(

const miseConfig = await miseService.getMiseConfiguration();

const notificationContent: string[] = [];
await Promise.allSettled(
configurableTools
.filter((tool) => tool.installed)
Expand All @@ -562,24 +582,49 @@ export function registerToolsCommands(
}

try {
await configureExtension({
tool: tool,
miseConfig: miseConfig,
configurableExtension: configurableTool,
useSymLinks: vscode.workspace
.getConfiguration("mise")
.get("configureExtensionsUseSymLinks"),
useShims: vscode.workspace
.getConfiguration("mise")
.get("configureExtensionsUseShims"),
});
const { configurableExtension, updatedKeys } =
await configureExtension({
tool: tool,
miseConfig: miseConfig,
configurableExtension: configurableTool,
useSymLinks: vscode.workspace
.getConfiguration("mise")
.get("configureExtensionsUseSymLinks"),
useShims: vscode.workspace
.getConfiguration("mise")
.get("configureExtensionsUseShims"),
});

if (updatedKeys.length === 0) {
return;
}

notificationContent.push(
`${configurableExtension.extensionName} (${updatedKeys.join(", ")} settings)`,
);
} catch (error) {
logger.error(
`Failed to configure the extension ${configurableTool.extensionName} for ${tool.name}: ${error}`,
);
}
}),
);
if (notificationContent.length === 0) {
return;
}

vscode.window
.showInformationMessage(
`Mise: Configured extensions:\n${notificationContent.join(",\n")}`,
"Show settings",
)
.then((selection) => {
if (selection === "Show settings") {
vscode.commands.executeCommand(
"workbench.action.openWorkspaceSettingsFile",
);
}
});
}),
);
}
20 changes: 5 additions & 15 deletions src/utils/configureExtensionUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ export async function configureExtension({
logger.error(
`Mise: Extension ${configurableExtension.extensionName} is not installed`,
);
return;
return { configurableExtension, updatedKeys: [] };
}

if (!getRootFolder()) {
logger.info(
`No workspace folders found, skipping extension configuration for: ${configurableExtension.extensionName}`,
);
return;
return { configurableExtension, updatedKeys: [] };
}

const extConfig = await configurableExtension.generateConfiguration(
Expand All @@ -117,18 +117,8 @@ export async function configureExtension({
);

if (updatedKeys.length === 0) {
return;
return { configurableExtension, updatedKeys: [] };
}
vscode.window
.showInformationMessage(
`Mise: Extension ${configurableExtension.extensionName} configured.\n${updatedKeys.join("\n")}`,
"Show settings",
)
.then((selection) => {
if (selection === "Show settings") {
vscode.commands.executeCommand(
"workbench.action.openWorkspaceSettingsFile",
);
}
});

return { configurableExtension, updatedKeys };
}

0 comments on commit 0c10571

Please sign in to comment.