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"
|
"category": "DevChat"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "DevChat.quickFix",
|
"command": "DevChat.quickFixAskDevChat",
|
||||||
"title": "DevChat Quick Fix",
|
"title": "Ask DevChat",
|
||||||
|
"category": "DevChat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "DevChat.quickFixUsingDevChat",
|
||||||
|
"title": "Ask DevChat",
|
||||||
"category": "DevChat"
|
"category": "DevChat"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -224,7 +229,11 @@
|
|||||||
"when": "false"
|
"when": "false"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "DevChat.quickFix",
|
"command": "DevChat.quickFixAskDevChat",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "DevChat.quickFixUsingDevChat",
|
||||||
"when": "false"
|
"when": "false"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -375,7 +375,7 @@ export function registerFixCommand(context: vscode.ExtensionContext) {
|
|||||||
|
|
||||||
export async function registerQuickFixCommand(context: vscode.ExtensionContext) {
|
export async function registerQuickFixCommand(context: vscode.ExtensionContext) {
|
||||||
let disposable = vscode.commands.registerCommand(
|
let disposable = vscode.commands.registerCommand(
|
||||||
"DevChat.quickFix",
|
"DevChat.quickFixAskDevChat",
|
||||||
async (document: vscode.TextDocument, range: vscode.Range | vscode.Selection, diagnostic: vscode.Diagnostic) => {
|
async (document: vscode.TextDocument, range: vscode.Range | vscode.Selection, diagnostic: vscode.Diagnostic) => {
|
||||||
ensureChatPanel(context);
|
ensureChatPanel(context);
|
||||||
if (!ExtensionContextHolder.provider?.view()) {
|
if (!ExtensionContextHolder.provider?.view()) {
|
||||||
@ -386,11 +386,27 @@ export async function registerQuickFixCommand(context: vscode.ExtensionContext)
|
|||||||
const editor = vscode.window.activeTextEditor;
|
const editor = vscode.window.activeTextEditor;
|
||||||
editor!.selection = new vscode.Selection(range.start, range.end);
|
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(disposable);
|
||||||
|
context.subscriptions.push(disposableFixUsingDevChat);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function waitForPanelActivation() {
|
async function waitForPanelActivation() {
|
||||||
|
@ -23,10 +23,16 @@ class DevChatQuickFixProvider implements vscode.CodeActionProvider {
|
|||||||
);
|
);
|
||||||
quickFix.isPreferred = false;
|
quickFix.isPreferred = false;
|
||||||
|
|
||||||
|
const fixUsingDevChat = new vscode.CodeAction(
|
||||||
|
"Fix using DevChat",
|
||||||
|
vscode.CodeActionKind.QuickFix,
|
||||||
|
);
|
||||||
|
fixUsingDevChat.isPreferred = true;
|
||||||
|
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
quickFix.command = {
|
quickFix.command = {
|
||||||
command: "DevChat.quickFix",
|
command: "DevChat.quickFixAskDevChat",
|
||||||
title: "DevChat Quick Fix",
|
title: "Ask DevChat",
|
||||||
arguments: [
|
arguments: [
|
||||||
document,
|
document,
|
||||||
range,
|
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]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,4 +64,3 @@ export default function registerQuickFixProvider() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user