diff --git a/package.json b/package.json index 33a6200..c508390 100644 --- a/package.json +++ b/package.json @@ -659,27 +659,27 @@ }, { "command": "devchat.addContext", - "title": "Add to DevChat" + "title": "Devchat:Add to DevChat" }, { "command": "devchat.askForCode", - "title": "Add to DevChat" + "title": "Devchat:Add to DevChat" }, { "command": "devchat.askForFile", - "title": "Add to DevChat" + "title": "Devchat:Add to DevChat" }, { "command": "devchat.addConext_chinese", - "title": "添加到DevChat" + "title": "Devchat:添加到DevChat" }, { "command": "devchat.askForCode_chinese", - "title": "添加到DevChat" + "title": "Devchat:添加到DevChat" }, { "command": "devchat.askForFile_chinese", - "title": "添加到DevChat" + "title": "Devchat:添加到DevChat" }, { "command": "DevChat.InstallCommands", @@ -703,19 +703,27 @@ }, { "command": "devchat.explain", - "title": "Generate Explain" + "title": "Devchat:Generate Explain" }, { "command": "devchat.explain_chinese", - "title": "代码解释" + "title": "Devchat:代码解释" }, { "command": "devchat.comments", - "title": "Generate Comments" + "title": "Devchat:Generate Comments" }, { "command": "devchat.comments_chinese", - "title": "生成注释" + "title": "Devchat:生成注释" + }, + { + "command": "devchat.fix", + "title": "Devchat:Fix this" + }, + { + "command": "devchat.fix_chinese", + "title": "Devchat:修复此" } ], "keybindings": [ @@ -819,6 +827,16 @@ "command": "devchat.comments_chinese", "when": "isChineseLocale && editorTextFocus && editorHasSelection", "group": "navigation" + }, + { + "command": "devchat.fix", + "when": "!isChineseLocale && editorTextFocus && editorHasSelection", + "group": "navigation" + }, + { + "command": "devchat.fix_chinese", + "when": "isChineseLocale && editorTextFocus && editorHasSelection", + "group": "navigation" } ] } diff --git a/src/contributes/commands.ts b/src/contributes/commands.ts index 1ddcd3b..f7fc048 100644 --- a/src/contributes/commands.ts +++ b/src/contributes/commands.ts @@ -470,7 +470,7 @@ export function registerCodeLensRangeCommand(context: vscode.ExtensionContext) { if (editor) { const range = new vscode.Range( new vscode.Position(pos.start, 0), - new vscode.Position(pos.end+1, 0) + new vscode.Position(pos.end + 1, 0) ); editor.selection = new vscode.Selection(range.start, range.end); } @@ -567,11 +567,31 @@ function registerCommentCommand(context: vscode.ExtensionContext) { ); } +function registerFixCommand(context: vscode.ExtensionContext) { + const callback = async () => { + const editor = vscode.window.activeTextEditor; + if (editor) { + if (!(await ensureChatPanel(context))) { + return; + } + + chatWithDevChat(ExtensionContextHolder.provider?.view()!, "/fix"); + } + }; + context.subscriptions.push( + vscode.commands.registerCommand("devchat.fix", callback) + ); + context.subscriptions.push( + vscode.commands.registerCommand("devchat.fix_chinese", callback) + ); +} + export { registerOpenChatPanelCommand, registerAddContextCommand, registerAskForCodeCommand, registerAskForFileCommand, registerExplainCommand, + registerFixCommand, registerCommentCommand, }; diff --git a/src/extension.ts b/src/extension.ts index 043f272..85ecdb5 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -17,6 +17,7 @@ import { registerExplainCommand, registerCodeLensRangeCommand, registerCommentCommand, + registerFixCommand, } from "./contributes/commands"; import { regLanguageContext } from "./contributes/context"; import { regDevChatView } from "./contributes/views"; @@ -371,9 +372,9 @@ async function configSetModelDefaultParams() { "Model.claude-3-opus": { max_input_tokens: 32000, }, - "Model.claude-3-sonnet": { - max_input_tokens: 32000, - }, + "Model.claude-3-sonnet": { + max_input_tokens: 32000, + }, "Model.xinghuo-2": { max_input_tokens: 6000, }, @@ -414,26 +415,23 @@ async function configSetModelDefaultParams() { } async function updateClaudePrivider() { - const claudeModels = [ - "Model.claude-3-opus", - "Model.claude-3-sonnet", - ]; + const claudeModels = ["Model.claude-3-opus", "Model.claude-3-sonnet"]; - for (const model of claudeModels) { - const modelConfig: any = UiUtilWrapper.getConfiguration("devchat", model); - if (modelConfig && Object.keys(modelConfig).length === 0) { - const modelProperties: any = { - "provider": "devchat" - }; - try { - await vscode.workspace - .getConfiguration("devchat") - .update(model, modelProperties, vscode.ConfigurationTarget.Global); - } catch (error) { - logger.channel()?.error(`update ${model} error: ${error}`); - } - } - } + for (const model of claudeModels) { + const modelConfig: any = UiUtilWrapper.getConfiguration("devchat", model); + if (modelConfig && Object.keys(modelConfig).length === 0) { + const modelProperties: any = { + provider: "devchat", + }; + try { + await vscode.workspace + .getConfiguration("devchat") + .update(model, modelProperties, vscode.ConfigurationTarget.Global); + } catch (error) { + logger.channel()?.error(`update ${model} error: ${error}`); + } + } + } } async function activate(context: vscode.ExtensionContext) { @@ -462,6 +460,7 @@ async function activate(context: vscode.ExtensionContext) { registerAskForCodeCommand(context); registerAskForFileCommand(context); registerExplainCommand(context); + registerFixCommand(context); registerCommentCommand(context); registerStatusBarItemClickCommand(context); diff --git a/src/panel/codeLens.ts b/src/panel/codeLens.ts index cc0da01..2031415 100644 --- a/src/panel/codeLens.ts +++ b/src/panel/codeLens.ts @@ -54,7 +54,7 @@ export class CodeLensManager { this.registrations = [ { elementType: "function", - objectName: "unit tests", + objectName: "Devchat:unit tests", promptGenerator: "/unit_tests {__filename__}:::{__functionName__}:::{__functionStartLine__}:::{__functionEndLine__}:::{__containerStartLine__}:::{__containerEndLine__}", }, diff --git a/workflowsCommands b/workflowsCommands index dbdb1ba..874da17 160000 --- a/workflowsCommands +++ b/workflowsCommands @@ -1 +1 @@ -Subproject commit dbdb1ba29db3536e4ae358113f4251b78845c879 +Subproject commit 874da1710f1c0e24b6c3078352919ef29b312638