Skip to content

Commit bc1ab8e

Browse files
authored
feat(code): disable editing in diff viewer (#1395)
## Problem files can be "edited" in the diff viewer (b side or unified view). the changes are not persisted, but users shouldn't be able to manually edit these in the first place <!-- Who is this for and what problem does it solve? --> <!-- Closes #ISSUE_ID --> ## [phc-editing-bug.mp4 <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.com/user-attachments/thumbnails/2eb83dcd-d847-4fb6-bbb2-c576e84f2847.mp4" />](https://app.graphite.com/user-attachments/video/2eb83dcd-d847-4fb6-bbb2-c576e84f2847.mp4) ## Changes updates diff viewer to disable editing, keeps 'revert' functionality working but removes ability to click/type ## notes i think we probably _should_ allow editing, but since nothing persists right now, it's just confusing so i'm disabling it for now <!-- What did you change and why? --> <!-- If there are frontend changes, include screenshots. --> ## How did you test this? manually <!-- Describe what you tested -- manual steps, automated tests, or both. --> <!-- If you're an agent, only list tests you actually ran. -->
1 parent 67e4f9f commit bc1ab8e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

apps/code/src/renderer/features/code-editor/components/CodeMirrorDiffEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function CodeMirrorDiffEditor({
3838
const toggleHideWhitespaceChanges = useDiffViewerStore(
3939
(s) => s.toggleHideWhitespaceChanges,
4040
);
41-
const extensions = useEditorExtensions(filePath, !onContentChange, true);
41+
const extensions = useEditorExtensions(filePath, true, true);
4242
const options = useMemo(
4343
() => ({
4444
original: originalContent,

apps/code/src/renderer/features/code-editor/hooks/useEditorExtensions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function useEditorExtensions(
3939
theme,
4040
mergeViewTheme,
4141
EditorView.editable.of(!readOnly),
42-
...(readOnly ? [EditorState.readOnly.of(true)] : []),
42+
...(readOnly && !isDiff ? [EditorState.readOnly.of(true)] : []),
4343
...(languageExtension ? [languageExtension] : []),
4444
];
4545
}, [filePath, isDarkMode, readOnly, isDiff, wordWrap]);

0 commit comments

Comments
 (0)