Merge pull request #581 from devchat-ai/add_fix_using_devchat
feat: Add new quick fix option using DevChat
This commit is contained in:
commit
2875f583a2
15
package.json
15
package.json
@ -170,8 +170,13 @@
|
||||
"category": "DevChat"
|
||||
},
|
||||
{
|
||||
"command": "DevChat.quickFix",
|
||||
"title": "DevChat Quick Fix",
|
||||
"command": "DevChat.quickFixAskDevChat",
|
||||
"title": "Ask DevChat",
|
||||
"category": "DevChat"
|
||||
},
|
||||
{
|
||||
"command": "DevChat.quickFixUsingDevChat",
|
||||
"title": "Ask DevChat",
|
||||
"category": "DevChat"
|
||||
}
|
||||
],
|
||||
@ -224,7 +229,11 @@
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "DevChat.quickFix",
|
||||
"command": "DevChat.quickFixAskDevChat",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
"command": "DevChat.quickFixUsingDevChat",
|
||||
"when": "false"
|
||||
},
|
||||
{
|
||||
|
@ -375,7 +375,7 @@ export function registerFixCommand(context: vscode.ExtensionContext) {
|
||||
|
||||
export async function registerQuickFixCommand(context: vscode.ExtensionContext) {
|
||||
let disposable = vscode.commands.registerCommand(
|
||||
"DevChat.quickFix",
|
||||
"DevChat.quickFixAskDevChat",
|
||||
async (document: vscode.TextDocument, range: vscode.Range | vscode.Selection, diagnostic: vscode.Diagnostic) => {
|
||||
ensureChatPanel(context);
|
||||
if (!ExtensionContextHolder.provider?.view()) {
|
||||
@ -386,11 +386,27 @@ export async function registerQuickFixCommand(context: vscode.ExtensionContext)
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
editor!.selection = new vscode.Selection(range.start, range.end);
|
||||
|
||||
chatWithDevChat(ExtensionContextHolder.provider?.view()!, "/fix_issue ");
|
||||
chatWithDevChat(ExtensionContextHolder.provider?.view()!, "/ask_issue ");
|
||||
}
|
||||
);
|
||||
let disposableFixUsingDevChat = vscode.commands.registerCommand(
|
||||
"DevChat.quickFixUsingDevChat",
|
||||
async (document: vscode.TextDocument, range: vscode.Range | vscode.Selection, diagnostic: vscode.Diagnostic) => {
|
||||
ensureChatPanel(context);
|
||||
if (!ExtensionContextHolder.provider?.view()) {
|
||||
await waitForPanelActivation();
|
||||
}
|
||||
|
||||
// select the code
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
editor!.selection = new vscode.Selection(range.start, range.end);
|
||||
|
||||
chatWithDevChat(ExtensionContextHolder.provider?.view()!, "/fix_issue ");
|
||||
}
|
||||
);
|
||||
|
||||
context.subscriptions.push(disposable);
|
||||
context.subscriptions.push(disposableFixUsingDevChat);
|
||||
}
|
||||
|
||||
async function waitForPanelActivation() {
|
||||
|
@ -23,10 +23,16 @@ class DevChatQuickFixProvider implements vscode.CodeActionProvider {
|
||||
);
|
||||
quickFix.isPreferred = false;
|
||||
|
||||
const fixUsingDevChat = new vscode.CodeAction(
|
||||
"Fix using DevChat",
|
||||
vscode.CodeActionKind.QuickFix,
|
||||
);
|
||||
fixUsingDevChat.isPreferred = true;
|
||||
|
||||
return new Promise(async (resolve) => {
|
||||
quickFix.command = {
|
||||
command: "DevChat.quickFix",
|
||||
title: "DevChat Quick Fix",
|
||||
command: "DevChat.quickFixAskDevChat",
|
||||
title: "Ask DevChat",
|
||||
arguments: [
|
||||
document,
|
||||
range,
|
||||
@ -34,7 +40,17 @@ class DevChatQuickFixProvider implements vscode.CodeActionProvider {
|
||||
],
|
||||
};
|
||||
|
||||
resolve([quickFix]);
|
||||
fixUsingDevChat.command = {
|
||||
command: "DevChat.quickFixUsingDevChat",
|
||||
title: "Fix using DevChat",
|
||||
arguments: [
|
||||
document,
|
||||
range,
|
||||
diagnostic,
|
||||
],
|
||||
};
|
||||
|
||||
resolve([quickFix, fixUsingDevChat]);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -47,5 +63,4 @@ export default function registerQuickFixProvider() {
|
||||
providedCodeActionKinds: DevChatQuickFixProvider.providedCodeActionKinds,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user