From 087abac34bccce11400549acb900687010925dca Mon Sep 17 00:00:00 2001 From: Bruno Vieira <bruno.vieira97@outlook.com> Date: Sun, 21 Jan 2024 14:31:48 -0300 Subject: [PATCH] read new setting and use default for language --- src/handler/SpecifyLanguageStep.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/handler/SpecifyLanguageStep.ts b/src/handler/SpecifyLanguageStep.ts index 2955ce1..49e7d3c 100644 --- a/src/handler/SpecifyLanguageStep.ts +++ b/src/handler/SpecifyLanguageStep.ts @@ -4,7 +4,7 @@ import { workspace } from "vscode"; import { instrumentOperationStep } from "vscode-extension-telemetry-wrapper"; import { serviceManager } from "../model"; -import { Language, MatadataType } from "../model/Metadata"; +import { Language, MetadataType } from "../model/Metadata"; import { IPickMetadata, IProjectMetadata, IStep } from "./HandlerInterfaces"; import { SpecifyGroupIdStep } from "./SpecifyGroupIdStep"; import { createPickBox } from "./utils"; @@ -30,17 +30,27 @@ export class SpecifyLanguageStep implements IStep { private async specifyLanguage(projectMetadata: IProjectMetadata): Promise<boolean> { const language: string = projectMetadata.defaults.language || workspace.getConfiguration("spring.initializr").get<string>("defaultLanguage"); + if (language) { projectMetadata.language = language && language.toLowerCase(); return true; } + + const items = await serviceManager.getItems(projectMetadata.serviceUrl, MetadataType.LANGUAGE); + + if (projectMetadata.enableSmartDefaults === true) { + projectMetadata.language = items.find(x => x.default === true)?.label.toLowerCase(); + return true; + } + const pickMetaData: IPickMetadata<Language> = { metadata: projectMetadata, title: "Spring Initializr: Specify project language", pickStep: SpecifyLanguageStep.getInstance(), placeholder: "Specify project language.", - items: serviceManager.getItems(projectMetadata.serviceUrl, MatadataType.LANGUAGE), + items: items }; + return await createPickBox(pickMetaData); } }