mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Refactor cline-diff
This commit is contained in:
@@ -5,6 +5,7 @@ import * as vscode from "vscode"
|
|||||||
import { ClineProvider } from "./core/webview/ClineProvider"
|
import { ClineProvider } from "./core/webview/ClineProvider"
|
||||||
import { createClineAPI } from "./exports"
|
import { createClineAPI } from "./exports"
|
||||||
import "./utils/path" // necessary to have access to String.prototype.toPosix
|
import "./utils/path" // necessary to have access to String.prototype.toPosix
|
||||||
|
import { DIFF_VIEW_URI_SCHEME } from "./integrations/editor/DiffViewProvider"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Built using https://github.com/microsoft/vscode-webview-ui-toolkit
|
Built using https://github.com/microsoft/vscode-webview-ui-toolkit
|
||||||
@@ -104,7 +105,7 @@ export function activate(context: vscode.ExtensionContext) {
|
|||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
context.subscriptions.push(
|
context.subscriptions.push(
|
||||||
vscode.workspace.registerTextDocumentContentProvider("claude-dev-diff", diffContentProvider)
|
vscode.workspace.registerTextDocumentContentProvider(DIFF_VIEW_URI_SCHEME, diffContentProvider)
|
||||||
)
|
)
|
||||||
|
|
||||||
// URI Handler
|
// URI Handler
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import { DecorationController } from "./DecorationController"
|
|||||||
import * as diff from "diff"
|
import * as diff from "diff"
|
||||||
import { diagnosticsToProblemsString, getNewDiagnostics } from "../diagnostics"
|
import { diagnosticsToProblemsString, getNewDiagnostics } from "../diagnostics"
|
||||||
|
|
||||||
|
export const DIFF_VIEW_URI_SCHEME = "cline-diff"
|
||||||
|
|
||||||
export class DiffViewProvider {
|
export class DiffViewProvider {
|
||||||
editType?: "create" | "modify"
|
editType?: "create" | "modify"
|
||||||
isEditing = false
|
isEditing = false
|
||||||
@@ -244,7 +246,7 @@ export class DiffViewProvider {
|
|||||||
.flatMap((tg) => tg.tabs)
|
.flatMap((tg) => tg.tabs)
|
||||||
.filter(
|
.filter(
|
||||||
(tab) =>
|
(tab) =>
|
||||||
tab.input instanceof vscode.TabInputTextDiff && tab.input?.original?.scheme === "claude-dev-diff"
|
tab.input instanceof vscode.TabInputTextDiff && tab.input?.original?.scheme === DIFF_VIEW_URI_SCHEME
|
||||||
)
|
)
|
||||||
for (const tab of tabs) {
|
for (const tab of tabs) {
|
||||||
// trying to close dirty views results in save popup
|
// trying to close dirty views results in save popup
|
||||||
@@ -265,7 +267,7 @@ export class DiffViewProvider {
|
|||||||
.find(
|
.find(
|
||||||
(tab) =>
|
(tab) =>
|
||||||
tab.input instanceof vscode.TabInputTextDiff &&
|
tab.input instanceof vscode.TabInputTextDiff &&
|
||||||
tab.input?.original?.scheme === "claude-dev-diff" &&
|
tab.input?.original?.scheme === DIFF_VIEW_URI_SCHEME &&
|
||||||
arePathsEqual(tab.input.modified.fsPath, uri.fsPath)
|
arePathsEqual(tab.input.modified.fsPath, uri.fsPath)
|
||||||
)
|
)
|
||||||
if (diffTab && diffTab.input instanceof vscode.TabInputTextDiff) {
|
if (diffTab && diffTab.input instanceof vscode.TabInputTextDiff) {
|
||||||
@@ -284,11 +286,11 @@ export class DiffViewProvider {
|
|||||||
})
|
})
|
||||||
vscode.commands.executeCommand(
|
vscode.commands.executeCommand(
|
||||||
"vscode.diff",
|
"vscode.diff",
|
||||||
vscode.Uri.parse(`claude-dev-diff:${fileName}`).with({
|
vscode.Uri.parse(`${DIFF_VIEW_URI_SCHEME}:${fileName}`).with({
|
||||||
query: Buffer.from(this.originalContent ?? "").toString("base64"),
|
query: Buffer.from(this.originalContent ?? "").toString("base64"),
|
||||||
}),
|
}),
|
||||||
uri,
|
uri,
|
||||||
`${fileName}: ${fileExists ? "Original ↔ Claude's Changes" : "New File"} (Editable)`
|
`${fileName}: ${fileExists ? "Original ↔ Cline's Changes" : "New File"} (Editable)`
|
||||||
)
|
)
|
||||||
// This should never happen but if it does it's worth investigating
|
// This should never happen but if it does it's worth investigating
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user