Skip to content

Commit 9e5c504

Browse files
hannesrudolphclaude
andcommitted
feat: add setting to disable diff visualization to prevent LSP crashes
Added a new setting `disableDiffVisualization` that allows users to disable the diff view when editing files. When enabled, files will open directly in the editor instead of showing a side-by-side diff view. This helps prevent Language Server Protocol (LSP) crashes that can occur with very large files, particularly affecting C# developers. The changes made by Roo are still visible in the chat window. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 2e2f83b commit 9e5c504

File tree

13 files changed

+81
-6
lines changed

13 files changed

+81
-6
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"roo-cline": patch
3+
---
4+
5+
Add setting to disable diff visualization to prevent LSP crashes
6+
7+
Added a new setting `disableDiffVisualization` that allows users to disable the diff view when editing files. When enabled, files will open directly in the editor instead of showing a side-by-side diff view. This helps prevent Language Server Protocol (LSP) crashes that can occur with very large files, particularly affecting C# developers. The changes made by Roo are still visible in the chat window.

packages/types/src/global-settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ export const globalSettingsSchema = z.object({
8383

8484
rateLimitSeconds: z.number().optional(),
8585
diffEnabled: z.boolean().optional(),
86+
disableDiffVisualization: z.boolean().optional(),
8687
fuzzyMatchThreshold: z.number().optional(),
8788
experiments: experimentsSchema.optional(),
8889

@@ -211,6 +212,7 @@ export const EVALS_SETTINGS: RooCodeSettings = {
211212
terminalShellIntegrationDisabled: true,
212213

213214
diffEnabled: true,
215+
disableDiffVisualization: false,
214216
fuzzyMatchThreshold: 1,
215217

216218
enableCheckpoints: false,

src/core/task/Task.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export type TaskOptions = {
104104
provider: ClineProvider
105105
apiConfiguration: ProviderSettings
106106
enableDiff?: boolean
107+
disableDiffVisualization?: boolean
107108
enableCheckpoints?: boolean
108109
fuzzyMatchThreshold?: number
109110
consecutiveMistakeLimit?: number
@@ -198,6 +199,7 @@ export class Task extends EventEmitter<ClineEvents> {
198199
provider,
199200
apiConfiguration,
200201
enableDiff = false,
202+
disableDiffVisualization = false,
201203
enableCheckpoints = true,
202204
fuzzyMatchThreshold = 1.0,
203205
consecutiveMistakeLimit = 3,
@@ -242,7 +244,7 @@ export class Task extends EventEmitter<ClineEvents> {
242244
this.consecutiveMistakeLimit = consecutiveMistakeLimit
243245
this.providerRef = new WeakRef(provider)
244246
this.globalStoragePath = provider.context.globalStorageUri.fsPath
245-
this.diffViewProvider = new DiffViewProvider(this.cwd)
247+
this.diffViewProvider = new DiffViewProvider(this.cwd, disableDiffVisualization)
246248
this.enableCheckpoints = enableCheckpoints
247249

248250
this.rootTask = rootTask

src/core/webview/ClineProvider.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ export class ClineProvider
529529
apiConfiguration,
530530
organizationAllowList,
531531
diffEnabled: enableDiff,
532+
disableDiffVisualization,
532533
enableCheckpoints,
533534
fuzzyMatchThreshold,
534535
experiments,
@@ -542,6 +543,7 @@ export class ClineProvider
542543
provider: this,
543544
apiConfiguration,
544545
enableDiff,
546+
disableDiffVisualization,
545547
enableCheckpoints,
546548
fuzzyMatchThreshold,
547549
task,
@@ -569,6 +571,7 @@ export class ClineProvider
569571
const {
570572
apiConfiguration,
571573
diffEnabled: enableDiff,
574+
disableDiffVisualization,
572575
enableCheckpoints,
573576
fuzzyMatchThreshold,
574577
experiments,
@@ -578,6 +581,7 @@ export class ClineProvider
578581
provider: this,
579582
apiConfiguration,
580583
enableDiff,
584+
disableDiffVisualization,
581585
enableCheckpoints,
582586
fuzzyMatchThreshold,
583587
historyItem,
@@ -1546,6 +1550,7 @@ export class ClineProvider
15461550
ttsEnabled: stateValues.ttsEnabled ?? false,
15471551
ttsSpeed: stateValues.ttsSpeed ?? 1.0,
15481552
diffEnabled: stateValues.diffEnabled ?? true,
1553+
disableDiffVisualization: stateValues.disableDiffVisualization ?? false,
15491554
enableCheckpoints: stateValues.enableCheckpoints ?? true,
15501555
soundVolume: stateValues.soundVolume,
15511556
browserViewportSize: stateValues.browserViewportSize ?? "900x600",

src/core/webview/webviewMessageHandler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ export const webviewMessageHandler = async (
645645
await updateGlobalState("diffEnabled", diffEnabled)
646646
await provider.postStateToWebview()
647647
break
648+
case "disableDiffVisualization":
649+
const disableDiffVisualization = message.bool ?? false
650+
await updateGlobalState("disableDiffVisualization", disableDiffVisualization)
651+
await provider.postStateToWebview()
652+
break
648653
case "enableCheckpoints":
649654
const enableCheckpoints = message.bool ?? true
650655
await updateGlobalState("enableCheckpoints", enableCheckpoints)

src/integrations/editor/DiffViewProvider.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ export class DiffViewProvider {
3434
private streamedLines: string[] = []
3535
private preDiagnostics: [vscode.Uri, vscode.Diagnostic[]][] = []
3636

37-
constructor(private cwd: string) {}
37+
constructor(
38+
private cwd: string,
39+
private disableDiffVisualization: boolean = false,
40+
) {}
3841

3942
async open(relPath: string): Promise<void> {
4043
this.relPath = relPath
@@ -92,7 +95,13 @@ export class DiffViewProvider {
9295
this.documentWasOpen = true
9396
}
9497

95-
this.activeDiffEditor = await this.openDiffEditor()
98+
// If diff visualization is disabled, open the file directly
99+
if (this.disableDiffVisualization) {
100+
const document = await vscode.workspace.openTextDocument(absolutePath)
101+
this.activeDiffEditor = await vscode.window.showTextDocument(document, { preview: false })
102+
} else {
103+
this.activeDiffEditor = await this.openDiffEditor()
104+
}
96105
this.fadedOverlayController = new DecorationController("fadedOverlay", this.activeDiffEditor)
97106
this.activeLineController = new DecorationController("activeLine", this.activeDiffEditor)
98107
// Apply faded overlay to all lines initially.

src/shared/ExtensionMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export type ExtensionState = Pick<
188188
| "terminalZdotdir"
189189
| "terminalCompressProgressBar"
190190
| "diffEnabled"
191+
| "disableDiffVisualization"
191192
| "fuzzyMatchThreshold"
192193
// | "experiments" // Optional in GlobalSettings, required here.
193194
| "language"

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export interface WebviewMessage {
8282
| "ttsSpeed"
8383
| "soundVolume"
8484
| "diffEnabled"
85+
| "disableDiffVisualization"
8586
| "enableCheckpoints"
8687
| "browserViewportSize"
8788
| "screenshotQuality"

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const ApiOptions = ({
7373
setErrorMessage,
7474
}: ApiOptionsProps) => {
7575
const { t } = useAppTranslation()
76-
const { organizationAllowList } = useExtensionState()
76+
const { organizationAllowList, disableDiffVisualization, setDisableDiffVisualization } = useExtensionState()
7777

7878
const [customHeaders, setCustomHeaders] = useState<[string, string][]>(() => {
7979
const headers = apiConfiguration?.openAiHeaders || {}
@@ -476,8 +476,19 @@ const ApiOptions = ({
476476
<>
477477
<DiffSettingsControl
478478
diffEnabled={apiConfiguration.diffEnabled}
479+
disableDiffVisualization={disableDiffVisualization}
479480
fuzzyMatchThreshold={apiConfiguration.fuzzyMatchThreshold}
480-
onChange={(field, value) => setApiConfigurationField(field, value)}
481+
onChange={(field, value) => {
482+
if (field === "disableDiffVisualization") {
483+
setDisableDiffVisualization(value)
484+
vscode.postMessage({
485+
type: "disableDiffVisualization",
486+
bool: value,
487+
})
488+
} else {
489+
setApiConfigurationField(field, value)
490+
}
491+
}}
481492
/>
482493
<TemperatureControl
483494
value={apiConfiguration.modelTemperature}

webview-ui/src/components/settings/DiffSettingsControl.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ import { VSCodeCheckbox } from "@vscode/webview-ui-toolkit/react"
55

66
interface DiffSettingsControlProps {
77
diffEnabled?: boolean
8+
disableDiffVisualization?: boolean
89
fuzzyMatchThreshold?: number
9-
onChange: (field: "diffEnabled" | "fuzzyMatchThreshold", value: any) => void
10+
onChange: (field: "diffEnabled" | "disableDiffVisualization" | "fuzzyMatchThreshold", value: any) => void
1011
}
1112

1213
export const DiffSettingsControl: React.FC<DiffSettingsControlProps> = ({
1314
diffEnabled = true,
15+
disableDiffVisualization = false,
1416
fuzzyMatchThreshold = 1.0,
1517
onChange,
1618
}) => {
@@ -23,6 +25,13 @@ export const DiffSettingsControl: React.FC<DiffSettingsControlProps> = ({
2325
[onChange],
2426
)
2527

28+
const handleDisableDiffVisualizationChange = useCallback(
29+
(e: any) => {
30+
onChange("disableDiffVisualization", e.target.checked)
31+
},
32+
[onChange],
33+
)
34+
2635
const handleThresholdChange = useCallback(
2736
(newValue: number[]) => {
2837
onChange("fuzzyMatchThreshold", newValue[0])
@@ -61,6 +70,19 @@ export const DiffSettingsControl: React.FC<DiffSettingsControlProps> = ({
6170
{t("settings:advanced.diff.matchPrecision.description")}
6271
</div>
6372
</div>
73+
74+
<div>
75+
<VSCodeCheckbox
76+
checked={disableDiffVisualization}
77+
onChange={handleDisableDiffVisualizationChange}>
78+
<span className="font-medium">
79+
{t("settings:advanced.diff.disableVisualization.label")}
80+
</span>
81+
</VSCodeCheckbox>
82+
<div className="text-vscode-descriptionForeground text-sm">
83+
{t("settings:advanced.diff.disableVisualization.description")}
84+
</div>
85+
</div>
6486
</div>
6587
)}
6688
</div>

0 commit comments

Comments
 (0)