Compare commits

...

6 Commits

Author SHA1 Message Date
Saoud Rizwan 7427994fba Create dirty-guests-shout.md 2025-04-11 21:54:07 -07:00
Saoud Rizwan 4b90ec3596 Add diff edit indicator 2025-04-11 21:39:54 -07:00
Saoud Rizwan a1ba0fd5ac Modify prompt to handle multi-edits to same file 2025-04-11 21:29:27 -07:00
Saoud Rizwan 366ffe8512 Modify prompts to handle large files 2025-04-11 21:21:47 -07:00
Saoud Rizwan d7a225ff34 Add quick scrolling animation between chunks of changes 2025-04-11 21:10:11 -07:00
Saoud Rizwan 126d953f45 Remove streaming animation between chunks of edits 2025-04-11 21:04:11 -07:00
5 changed files with 55 additions and 7 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
Improve diff editing animation and prompts for large files; show diff edits indicator next to file path
+1 -1
View File
@@ -284,7 +284,7 @@ export async function constructNewFileContent(diffContent: string, originalConte
;[searchMatchIndex, searchEndIndex] = blockMatch
} else {
throw new Error(
`The SEARCH block:\n${currentSearchContent.trimEnd()}\n...does not match anything in the file.`,
`The SEARCH block:\n${currentSearchContent.trimEnd()}\n...does not match anything in the file or was searched out of order in the provided blocks.`,
)
}
}
+1 -1
View File
@@ -196,7 +196,7 @@ Otherwise, if you have not completed the task and do not need additional informa
`This is likely because the SEARCH block content doesn't match exactly with what's in the file, or if you used multiple SEARCH/REPLACE blocks they may not have been in the order they appear in the file.\n\n` +
`The file was reverted to its original state:\n\n` +
`<file_content path="${relPath.toPosix()}">\n${originalContent}\n</file_content>\n\n` +
`Now that you have the latest state of the file, try the operation again with fewer/more precise SEARCH blocks.\n(If you run into this error 3 times in a row, you may use the write_to_file tool as a fallback. Keep in mind, the write_to_file fallback is far from ideal, as this means you'll be re-writing the entire contents of the file just to make a few edits, which takes time and money. So let's bias towards using replace_in_file as effectively as possible)`,
`Now that you have the latest state of the file, try the operation again with fewer more precise SEARCH blocks. It may be prudent, especially for large files, to try to limit yourself to 1-3 SEARCH/REPLACE blocks at a time, then wait for the user to respond with the result of the operation before following up with another replace_in_file call to make additional edits.\n(If you run into this error 3 times in a row, you may use the write_to_file tool as a fallback.)`,
toolAlreadyUsed: (toolName: string) =>
`Tool [${toolName}] was not executed because a tool has already been used in this message. Only one tool may be used per message. You must assess the first tool's result before proceeding to use the next tool.`,
+29 -5
View File
@@ -105,8 +105,11 @@ export class DiffViewProvider {
const beginningOfDocument = new vscode.Position(0, 0)
diffEditor.selection = new vscode.Selection(beginningOfDocument, beginningOfDocument)
for (let i = 0; i < diffLines.length; i++) {
const currentLine = this.streamedLines.length + i
// Instead of animating each line, we'll update in larger chunks
const currentLine = this.streamedLines.length + diffLines.length - 1
if (currentLine >= 0) {
// Only proceed if we have new lines
// Replace all content up to the current line with accumulated lines
// This is necessary (as compared to inserting one line at a time) to handle cases where html tags on previous lines are auto closed for example
const edit = new vscode.WorkspaceEdit()
@@ -114,12 +117,33 @@ export class DiffViewProvider {
const contentToReplace = accumulatedLines.slice(0, currentLine + 1).join("\n") + "\n"
edit.replace(document.uri, rangeToReplace, contentToReplace)
await vscode.workspace.applyEdit(edit)
// Update decorations
// Update decorations for the entire changed section
this.activeLineController.setActiveLine(currentLine)
this.fadedOverlayController.updateOverlayAfterLine(currentLine, document.lineCount)
// Scroll to the current line
this.scrollEditorToLine(currentLine)
// Scroll to the last changed line
if (diffLines.length <= 5) {
// For small changes, just jump directly to the line
this.scrollEditorToLine(currentLine)
} else {
// For larger changes, create a quick scrolling animation
const startLine = this.streamedLines.length
const endLine = currentLine
const totalLines = endLine - startLine
const numSteps = 10 // Adjust this number to control animation speed
const stepSize = Math.max(1, Math.floor(totalLines / numSteps))
// Create and await the smooth scrolling animation
for (let line = startLine; line <= endLine; line += stepSize) {
this.activeDiffEditor?.revealRange(new vscode.Range(line, 0, line, 0), vscode.TextEditorRevealType.InCenter)
await new Promise((resolve) => setTimeout(resolve, 16)) // ~60fps
}
// Ensure we end at the final line
this.scrollEditorToLine(currentLine)
}
}
// Update the streamedLines with the new accumulated content
this.streamedLines = accumulatedLines
if (isFinal) {
@@ -38,6 +38,13 @@ const CodeAccordian = ({
[path, language, code],
)
const numberOfEdits = useMemo(() => {
if (code) {
return (code.match(/>>>>>>> REPLACE/g) || []).length || undefined
}
return undefined
}, [code])
return (
<div
style={{
@@ -95,6 +102,18 @@ const CodeAccordian = ({
</>
)}
<div style={{ flexGrow: 1 }}></div>
{numberOfEdits !== undefined && (
<div
style={{
display: "flex",
alignItems: "center",
marginRight: "8px",
color: "var(--vscode-descriptionForeground)",
}}>
<span className="codicon codicon-diff-single" style={{ marginRight: "4px" }}></span>
<span>{numberOfEdits}</span>
</div>
)}
<span className={`codicon codicon-chevron-${isExpanded ? "up" : "down"}`}></span>
</div>
)}