mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 04:11:10 -05:00
Speed up diff edits
This commit is contained in:
5
.changeset/smooth-jokes-hammer.md
Normal file
5
.changeset/smooth-jokes-hammer.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"roo-cline": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Speed up diff editing (thanks @hannesrudolph!)
|
||||||
@@ -88,7 +88,6 @@ export class DiffViewProvider {
|
|||||||
if (!isFinal) {
|
if (!isFinal) {
|
||||||
accumulatedLines.pop() // remove the last partial line only if it's not the final update
|
accumulatedLines.pop() // remove the last partial line only if it's not the final update
|
||||||
}
|
}
|
||||||
const diffLines = accumulatedLines.slice(this.streamedLines.length)
|
|
||||||
|
|
||||||
const diffEditor = this.activeDiffEditor
|
const diffEditor = this.activeDiffEditor
|
||||||
const document = diffEditor?.document
|
const document = diffEditor?.document
|
||||||
@@ -100,21 +99,19 @@ export class DiffViewProvider {
|
|||||||
const beginningOfDocument = new vscode.Position(0, 0)
|
const beginningOfDocument = new vscode.Position(0, 0)
|
||||||
diffEditor.selection = new vscode.Selection(beginningOfDocument, beginningOfDocument)
|
diffEditor.selection = new vscode.Selection(beginningOfDocument, beginningOfDocument)
|
||||||
|
|
||||||
for (let i = 0; i < diffLines.length; i++) {
|
const endLine = accumulatedLines.length
|
||||||
const currentLine = this.streamedLines.length + i
|
// Replace all content up to the current line with accumulated lines
|
||||||
// Replace all content up to the current line with accumulated lines
|
const edit = new vscode.WorkspaceEdit()
|
||||||
// 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 rangeToReplace = new vscode.Range(0, 0, endLine + 1, 0)
|
||||||
const edit = new vscode.WorkspaceEdit()
|
const contentToReplace = accumulatedLines.slice(0, endLine + 1).join("\n") + "\n"
|
||||||
const rangeToReplace = new vscode.Range(0, 0, currentLine + 1, 0)
|
edit.replace(document.uri, rangeToReplace, contentToReplace)
|
||||||
const contentToReplace = accumulatedLines.slice(0, currentLine + 1).join("\n") + "\n"
|
await vscode.workspace.applyEdit(edit)
|
||||||
edit.replace(document.uri, rangeToReplace, contentToReplace)
|
// Update decorations
|
||||||
await vscode.workspace.applyEdit(edit)
|
this.activeLineController.setActiveLine(endLine)
|
||||||
// Update decorations
|
this.fadedOverlayController.updateOverlayAfterLine(endLine, document.lineCount)
|
||||||
this.activeLineController.setActiveLine(currentLine)
|
// Scroll to the current line
|
||||||
this.fadedOverlayController.updateOverlayAfterLine(currentLine, document.lineCount)
|
this.scrollEditorToLine(endLine)
|
||||||
// Scroll to the current line
|
|
||||||
this.scrollEditorToLine(currentLine)
|
|
||||||
}
|
|
||||||
// Update the streamedLines with the new accumulated content
|
// Update the streamedLines with the new accumulated content
|
||||||
this.streamedLines = accumulatedLines
|
this.streamedLines = accumulatedLines
|
||||||
if (isFinal) {
|
if (isFinal) {
|
||||||
|
|||||||
Reference in New Issue
Block a user