Move save() and getDocument() to the platform specific diff classes (#5008)
* Move logic to save the diff document and get the diff content to the platform specific diff view providers. Add getDocumentText to the diff service. The ExternalDiffViewProvider should be using its activeDiffEditorId (not the activeDiffEditor, which is the vscode Editor object) * Check activeDiffEditorId * Update src/integrations/editor/DiffViewProvider.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Use await with this.saveDocument() * Remove test file --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
72f16a8c30
commit
a9e526e99b
8 files changed
+93
-55
No files matched your search
@@ -84,7 +84,7 @@ export class VscodeDiffViewProvider extends DiffViewProvider {
|
||||
override async replaceText(
|
||||
content: string,
|
||||
rangeToReplace: { startLine: number; endLine: number },
|
||||
currentLine: number,
|
||||
currentLine: number | undefined,
|
||||
): Promise<void> {
|
||||
if (!this.activeDiffEditor || !this.activeDiffEditor.document) {
|
||||
throw new Error("User closed text editor, unable to edit file...")
|
||||
@@ -100,9 +100,11 @@ export class VscodeDiffViewProvider extends DiffViewProvider {
|
||||
edit.replace(document.uri, range, content)
|
||||
await vscode.workspace.applyEdit(edit)
|
||||
|
||||
// Update decorations for the entire changed section
|
||||
this.activeLineController?.setActiveLine(currentLine)
|
||||
this.fadedOverlayController?.updateOverlayAfterLine(currentLine, document.lineCount)
|
||||
if (currentLine !== undefined) {
|
||||
// Update decorations for the entire changed section
|
||||
this.activeLineController?.setActiveLine(currentLine)
|
||||
this.fadedOverlayController?.updateOverlayAfterLine(currentLine, document.lineCount)
|
||||
}
|
||||
}
|
||||
|
||||
override async scrollEditorToLine(line: number): Promise<void> {
|
||||
@@ -143,6 +145,22 @@ export class VscodeDiffViewProvider extends DiffViewProvider {
|
||||
this.activeLineController?.clear()
|
||||
}
|
||||
|
||||
protected override async getDocumentText(): Promise<string | undefined> {
|
||||
if (!this.activeDiffEditor || !this.activeDiffEditor.document) {
|
||||
return undefined
|
||||
}
|
||||
return this.activeDiffEditor.document.getText()
|
||||
}
|
||||
|
||||
protected override async saveDocument(): Promise<void> {
|
||||
if (!this.activeDiffEditor) {
|
||||
return
|
||||
}
|
||||
if (this.activeDiffEditor.document.isDirty) {
|
||||
await this.activeDiffEditor.document.save()
|
||||
}
|
||||
}
|
||||
|
||||
protected async closeDiffView(): Promise<void> {
|
||||
// Close all the cline diff views.
|
||||
const tabs = vscode.window.tabGroups.all
|
||||
|
||||
Reference in new issue
Block a user