Make reveal range operation safer

This commit is contained in:
Saoud Rizwan
2024-09-10 23:50:10 -04:00
parent dc2dc8d5b4
commit e5979eed3c
2 changed files with 20 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
"name": "claude-dev",
"displayName": "Claude Dev",
"description": "Autonomous coding agent right in your IDE, capable of creating/editing files, executing commands, and more with your permission every step of the way.",
"version": "1.6.3",
"version": "1.6.4",
"icon": "icons/icon.png",
"galleryBanner": {
"color": "#F9E1D2",

View File

@@ -855,11 +855,24 @@ export class ClaudeDev {
if (part.added || part.removed) {
const startLine = lineCount + 1
const endLine = lineCount + (part.count || 0)
vscode.window.activeTextEditor?.revealRange(
const activeEditor = vscode.window.activeTextEditor
if (activeEditor) {
try {
activeEditor.revealRange(
// + 3 to move the editor up slightly as this looks better
new vscode.Range(new vscode.Position(startLine, 0), new vscode.Position(endLine + 3, 0)),
new vscode.Range(
new vscode.Position(startLine, 0),
new vscode.Position(
Math.min(endLine + 3, activeEditor.document.lineCount - 1),
0
)
),
vscode.TextEditorRevealType.InCenter
)
} catch (error) {
console.error(`Error revealing range for ${absolutePath}: ${error}`)
}
}
break
}
lineCount += part.count || 0
@@ -1558,7 +1571,7 @@ ${this.customInstructions.trim()}
const { response, text, images } = await this.ask(
"mistake_limit_reached",
this.api.getModel().id.includes("claude")
? `This may indicate a failure in his thought process or inability to use a tool properly, which can be mitigated with some user guidance (e.g. "let's try breaking this large file down into smaller files").`
? `This may indicate a failure in his thought process or inability to use a tool properly, which can be mitigated with some user guidance (e.g. "Try breaking down the task into smaller steps").`
: "Claude Dev uses complex prompts and iterative task execution that may be challenging for less capable models. For best results, it's recommended to use Claude 3.5 Sonnet for its advanced agentic coding capabilities."
)
if (response === "messageResponse") {