Skip to content

Commit 12f16a4

Browse files
deepcodinghellodeepcodingmanellipsis-dev[bot]dcbartlett
authored
Added option for skipping diff animation. Useful when diff animation … (RooCodeInc#1765)
* Added option for skipping diff animation. Useful when diff animation is slow. * Update README.md Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * fixed copyright symbol and default value * Update README.md --------- Co-authored-by: Mandeep Kumar <[email protected]> Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Dennis Bartlett <[email protected]>
1 parent bc7d6f0 commit 12f16a4

File tree

5 files changed

+53
-15
lines changed

5 files changed

+53
-15
lines changed

.changeset/moody-rules-repeat.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
Added option for skipping diff animation. Useful when diff animation is slow.

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,14 @@ For example, when working with a local web server, you can use 'Restore Workspac
137137

138138
<img width="2000" height="0" src="https://github.com/user-attachments/assets/ee14e6f7-20b8-4391-9091-8e8e25561929"><br>
139139

140+
## Settings
141+
142+
Cline provides several settings to customize its behavior:
143+
144+
### Editor Settings
145+
146+
- `cline.editor.skipDiffAnimation`: Disable the animated diff view when Cline makes changes to files. This can significantly speed up file modifications, especially when working with remote repositories. Default: `false`
147+
140148
## Contributing
141149

142150
To contribute to the project, start with our [Contributing Guide](CONTRIBUTING.md) to learn the basics. You can also join our [Discord](https://discord.gg/cline) to chat with other contributors in the `#contributors` channel. If you're looking for full-time work, check out our open positions on our [careers page](https://cline.bot/join-us)!

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@
182182
"default": null,
183183
"description": "Path to Chrome executable for browser use functionality. If not set, the extension will attempt to find or download it automatically."
184184
},
185+
"cline.editor.skipDiffAnimation": {
186+
"type": "boolean",
187+
"default": false,
188+
"description": "Skip the animation when applying diffs in the editor. Useful for faster updates, especially with remote repositories."
189+
},
185190
"cline.preferredLanguage": {
186191
"type": "string",
187192
"enum": [

src/integrations/editor/DiffViewProvider.ts

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class DiffViewProvider {
1414
editType?: "create" | "modify"
1515
isEditing = false
1616
originalContent: string | undefined
17+
skipAnimation = false
1718
private createdDirs: string[] = []
1819
private documentWasOpen = false
1920
private relPath?: string
@@ -24,7 +25,9 @@ export class DiffViewProvider {
2425
private streamedLines: string[] = []
2526
private preDiagnostics: [vscode.Uri, vscode.Diagnostic[]][] = []
2627

27-
constructor(private cwd: string) {}
28+
constructor(private cwd: string) {
29+
this.skipAnimation = vscode.workspace.getConfiguration("cline.editor").get("skipDiffAnimation", false)
30+
}
2831

2932
async open(relPath: string): Promise<void> {
3033
this.relPath = relPath
@@ -92,27 +95,37 @@ export class DiffViewProvider {
9295
throw new Error("User closed text editor, unable to edit file...")
9396
}
9497

95-
// Place cursor at the beginning of the diff editor to keep it out of the way of the stream animation
98+
// Place cursor at the beginning of the diff editor
9699
const beginningOfDocument = new vscode.Position(0, 0)
97100
diffEditor.selection = new vscode.Selection(beginningOfDocument, beginningOfDocument)
98101

99-
for (let i = 0; i < diffLines.length; i++) {
100-
const currentLine = this.streamedLines.length + i
101-
// Replace all content up to the current line with accumulated lines
102-
// 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
102+
if (this.skipAnimation) {
103+
// Apply all changes at once if animation is disabled
103104
const edit = new vscode.WorkspaceEdit()
104-
const rangeToReplace = new vscode.Range(0, 0, currentLine + 1, 0)
105-
const contentToReplace = accumulatedLines.slice(0, currentLine + 1).join("\n") + "\n"
105+
const rangeToReplace = new vscode.Range(0, 0, document.lineCount, 0)
106+
const contentToReplace = accumulatedLines.join("\n") + "\n"
106107
edit.replace(document.uri, rangeToReplace, contentToReplace)
107108
await vscode.workspace.applyEdit(edit)
108-
// Update decorations
109-
this.activeLineController.setActiveLine(currentLine)
110-
this.fadedOverlayController.updateOverlayAfterLine(currentLine, document.lineCount)
111-
// Scroll to the current line
112-
this.scrollEditorToLine(currentLine)
109+
this.streamedLines = accumulatedLines
110+
} else {
111+
// Original animation logic
112+
for (let i = 0; i < diffLines.length; i++) {
113+
const currentLine = this.streamedLines.length + i
114+
const edit = new vscode.WorkspaceEdit()
115+
const rangeToReplace = new vscode.Range(0, 0, currentLine + 1, 0)
116+
const contentToReplace = accumulatedLines.slice(0, currentLine + 1).join("\n") + "\n"
117+
edit.replace(document.uri, rangeToReplace, contentToReplace)
118+
await vscode.workspace.applyEdit(edit)
119+
// Update decorations
120+
this.activeLineController.setActiveLine(currentLine)
121+
this.fadedOverlayController.updateOverlayAfterLine(currentLine, document.lineCount)
122+
// Scroll to the current line
123+
this.scrollEditorToLine(currentLine)
124+
}
125+
// Update the streamedLines with the new accumulated content
126+
this.streamedLines = accumulatedLines
113127
}
114-
// Update the streamedLines with the new accumulated content
115-
this.streamedLines = accumulatedLines
128+
116129
if (isFinal) {
117130
// Handle any remaining lines if the new content is shorter than the original
118131
if (this.streamedLines.length < document.lineCount) {

src/shared/EditorSettings.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface EditorSettings {
2+
skipDiffAnimation: boolean
3+
}
4+
5+
export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
6+
skipDiffAnimation: false,
7+
}

0 commit comments

Comments
 (0)