Update the diff service to use a unique id to track open diff editor in external platforms. Store the diff Id in the ExternalDiffViewEditor when the diff is opened. It will serve the same purpose as the activeDiffEditor property on vscode, it can be used to manipulate the diff editor tab. Add the implementation of replaceText in the ExternalDiffViewEditor.
29 lines
884 B
TypeScript
29 lines
884 B
TypeScript
import { getHostBridgeProvider } from "@/hosts/host-providers"
|
|
import { DiffViewProvider } from "@/integrations/editor/DiffViewProvider"
|
|
|
|
export class ExternalDiffViewProvider extends DiffViewProvider {
|
|
private activeDiffEditorId: string | undefined
|
|
override async openDiffEditor(): Promise<void> {
|
|
if (!this.absolutePath) {
|
|
return
|
|
}
|
|
const response = await getHostBridgeProvider().diffClient.openDiff({
|
|
path: this.absolutePath,
|
|
content: this.originalContent ?? "",
|
|
})
|
|
this.activeDiffEditorId = response.diffId
|
|
}
|
|
override async replaceText(
|
|
content: string,
|
|
rangeToReplace: { startLine: number; endLine: number },
|
|
_currentLine: number,
|
|
): Promise<void> {
|
|
await getHostBridgeProvider().diffClient.replaceText({
|
|
diffId: this.activeDiffEditorId,
|
|
content: content,
|
|
startLine: rangeToReplace.startLine,
|
|
endLine: rangeToReplace.endLine,
|
|
})
|
|
}
|
|
}
|