Polish extension

This commit is contained in:
aboyko
2024-05-17 15:12:03 -04:00
parent fe953bde5b
commit b50fef99ba
11 changed files with 250 additions and 98 deletions

View File

@@ -2,19 +2,33 @@ import { Uri, commands, window } from "vscode";
import { CLI } from "./extension";
import { enterText, getTargetPomXml } from "./utils";
import path from "path";
import { handleGuideApply } from "./guide";
import { handleGuideApplyWorkspaceEdit } from "./guide";
import { CANCELLED } from "./cli";
export async function handleAiAdd(pom: Uri) {
if (!pom) {
pom = await getTargetPomXml();
let question: string;
try {
if (!pom) {
pom = await getTargetPomXml();
}
question = await enterText({
title: "Question",
prompt: "Enter question to LLM",
});
} catch (error) {
// ignore: cancellation via UI
}
const question = await enterText({
title: "Question",
prompt: "Enter question to LLM",
});
const uri = await CLI.aiAdd(question, path.dirname(pom.fsPath));
await commands.executeCommand("markdown.showPreview", uri);
if ("Yes" === await window.showInformationMessage(`Apply guide '${path.basename(uri.fsPath)}' to the project?`, "Yes", "No")) {
handleGuideApply(uri);
try {
if (question.trim().length > 0) {
const uri = await CLI.aiAdd(question, path.dirname(pom.fsPath));
await commands.executeCommand("markdown.showPreview", uri);
if ("Yes" === await window.showInformationMessage(`Apply guide '${path.basename(uri.fsPath)}' to the project?`, "Yes", "No")) {
handleGuideApplyWorkspaceEdit(uri);
}
}
} catch (error) {
if (error !== CANCELLED) {
window.showErrorMessage(error);
}
}
}