Only calc diff to scroll to if fileExists

This commit is contained in:
Saoud Rizwan
2024-09-10 21:48:21 -04:00
parent 74ac4a69aa
commit 1958cb1536

View File

@@ -848,20 +848,22 @@ export class ClaudeDev {
await vscode.workspace.applyEdit(edit) // has the added benefit of maintaing the file's original EOLs await vscode.workspace.applyEdit(edit) // has the added benefit of maintaing the file's original EOLs
// Find the first range where the content differs and scroll to it // Find the first range where the content differs and scroll to it
const diffResult = diff.diffLines(originalContent, newContent) if (fileExists) {
for (let i = 0, lineCount = 0; i < diffResult.length; i++) { const diffResult = diff.diffLines(originalContent, newContent)
const part = diffResult[i] for (let i = 0, lineCount = 0; i < diffResult.length; i++) {
if (part.added || part.removed) { const part = diffResult[i]
const startLine = lineCount + 1 if (part.added || part.removed) {
const endLine = lineCount + (part.count || 0) const startLine = lineCount + 1
vscode.window.activeTextEditor?.revealRange( const endLine = lineCount + (part.count || 0)
// + 3 to move the editor up slightly as this looks better vscode.window.activeTextEditor?.revealRange(
new vscode.Range(new vscode.Position(startLine, 0), new vscode.Position(endLine + 3, 0)), // + 3 to move the editor up slightly as this looks better
vscode.TextEditorRevealType.InCenter new vscode.Range(new vscode.Position(startLine, 0), new vscode.Position(endLine + 3, 0)),
) vscode.TextEditorRevealType.InCenter
break )
break
}
lineCount += part.count || 0
} }
lineCount += part.count || 0
} }
// remove cursor from the document // remove cursor from the document