Skip to content

Commit 7909ee1

Browse files
committed
refactor: improve diff view label constant to include full text
- Rename DIFF_VIEW_LABEL_SEPARATOR to DIFF_VIEW_LABEL_CHANGES - Include full 'Original ↔ Roo's Changes' text in constant for better maintainability - Update all usages in DiffViewProvider.ts and test file - Addresses feedback to make constant changes less awkward
1 parent c9335a7 commit 7909ee1

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/integrations/editor/DiffViewProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Task } from "../../core/task/Task"
1515
import { DecorationController } from "./DecorationController"
1616

1717
export const DIFF_VIEW_URI_SCHEME = "cline-diff"
18-
export const DIFF_VIEW_LABEL_SEPARATOR = "↔ Roo's Changes"
18+
export const DIFF_VIEW_LABEL_CHANGES = "Original ↔ Roo's Changes"
1919

2020
// TODO: https://github.com/cline/cline/pull/3354
2121
export class DiffViewProvider {
@@ -398,7 +398,7 @@ export class DiffViewProvider {
398398
// Also check by tab label for our specific diff views
399399
// This catches cases where the diff view might be created differently
400400
// when files are pre-opened as text documents
401-
if (tab.label.includes(DIFF_VIEW_LABEL_SEPARATOR) && !tab.isDirty) {
401+
if (tab.label.includes(DIFF_VIEW_LABEL_CHANGES) && !tab.isDirty) {
402402
return true
403403
}
404404

@@ -513,7 +513,7 @@ export class DiffViewProvider {
513513
query: Buffer.from(this.originalContent ?? "").toString("base64"),
514514
}),
515515
uri,
516-
`${fileName}: ${fileExists ? `Original ${DIFF_VIEW_LABEL_SEPARATOR}` : "New File"} (Editable)`,
516+
`${fileName}: ${fileExists ? `${DIFF_VIEW_LABEL_CHANGES}` : "New File"} (Editable)`,
517517
{ preserveFocus: true },
518518
)
519519
})

src/integrations/editor/__tests__/DiffViewProvider.spec.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DiffViewProvider, DIFF_VIEW_URI_SCHEME, DIFF_VIEW_LABEL_SEPARATOR } from "../DiffViewProvider"
1+
import { DiffViewProvider, DIFF_VIEW_URI_SCHEME, DIFF_VIEW_LABEL_CHANGES } from "../DiffViewProvider"
22
import * as vscode from "vscode"
33
import * as path from "path"
44

@@ -219,7 +219,7 @@ describe("DiffViewProvider", () => {
219219
"vscode.diff",
220220
expect.any(Object),
221221
expect.any(Object),
222-
`test.md: Original ${DIFF_VIEW_LABEL_SEPARATOR} (Editable)`,
222+
`test.md: ${DIFF_VIEW_LABEL_CHANGES} (Editable)`,
223223
{ preserveFocus: true },
224224
)
225225
})
@@ -255,7 +255,7 @@ describe("DiffViewProvider", () => {
255255
original: { scheme: DIFF_VIEW_URI_SCHEME },
256256
modified: { fsPath: "/test/file1.ts" },
257257
},
258-
label: `file1.ts: Original ${DIFF_VIEW_LABEL_SEPARATOR} (Editable)`,
258+
label: `file1.ts: ${DIFF_VIEW_LABEL_CHANGES} (Editable)`,
259259
isDirty: false,
260260
},
261261
// Diff view identified by label (for pre-opened files)
@@ -265,7 +265,7 @@ describe("DiffViewProvider", () => {
265265
original: { scheme: "file" }, // Different scheme due to pre-opening
266266
modified: { fsPath: "/test/file2.md" },
267267
},
268-
label: `file2.md: Original ${DIFF_VIEW_LABEL_SEPARATOR} (Editable)`,
268+
label: `file2.md: ${DIFF_VIEW_LABEL_CHANGES} (Editable)`,
269269
isDirty: false,
270270
},
271271
// Regular file tab (should not be closed)
@@ -284,7 +284,7 @@ describe("DiffViewProvider", () => {
284284
original: { scheme: DIFF_VIEW_URI_SCHEME },
285285
modified: { fsPath: "/test/file4.ts" },
286286
},
287-
label: `file4.ts: Original ${DIFF_VIEW_LABEL_SEPARATOR} (Editable)`,
287+
label: `file4.ts: ${DIFF_VIEW_LABEL_CHANGES} (Editable)`,
288288
isDirty: true,
289289
},
290290
]
@@ -317,15 +317,13 @@ describe("DiffViewProvider", () => {
317317

318318
// Verify that only the appropriate tabs were closed
319319
expect(closedTabs).toHaveLength(2)
320-
expect(closedTabs[0].label).toBe(`file1.ts: Original ${DIFF_VIEW_LABEL_SEPARATOR} (Editable)`)
321-
expect(closedTabs[1].label).toBe(`file2.md: Original ${DIFF_VIEW_LABEL_SEPARATOR} (Editable)`)
320+
expect(closedTabs[0].label).toBe(`file1.ts: ${DIFF_VIEW_LABEL_CHANGES} (Editable)`)
321+
expect(closedTabs[1].label).toBe(`file2.md: ${DIFF_VIEW_LABEL_CHANGES} (Editable)`)
322322

323323
// Verify that the regular file and dirty diff were not closed
324324
expect(closedTabs.find((t) => t.label === "file3.js")).toBeUndefined()
325325
expect(
326-
closedTabs.find(
327-
(t) => t.label === `file4.ts: Original ${DIFF_VIEW_LABEL_SEPARATOR} (Editable)` && t.isDirty,
328-
),
326+
closedTabs.find((t) => t.label === `file4.ts: ${DIFF_VIEW_LABEL_CHANGES} (Editable)` && t.isDirty),
329327
).toBeUndefined()
330328
})
331329
})

0 commit comments

Comments
 (0)