Skip to content

feat: editable diff views for unstaged changes - #107

Merged
nwparker merged 1 commit into
mainfrom
nwparker/edit-sourcegraph-files
Mar 26, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/edit-sourcegraph-files

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

Summary

  • Makes the modified (right) side of diff views editable for unstaged files, matching VS Code and Zed behavior
  • Staged diffs remain read-only (the right side shows the index version, editing would be confusing)
  • Works in both single-file diff view (DiffViewer) and combined "View All Changes" view (CombinedDiffViewer)
  • Supports Cmd/Ctrl+S to save edits back to the working tree file, with dirty state tracking

Changes

  • DiffViewer.tsx: Added editable, onContentChange, onSave props. Wires up the modified editor with Cmd+S keybinding and change tracking via refs.
  • EditorPanel.tsx: Extended handleContentChange and handleSave to support diff-mode files. Passes editable props to DiffViewer for unstaged diffs. Tracks edit buffers for diff files.
  • CombinedDiffViewer.tsx: Added per-section editable support with dirty tracking. Unstaged sections are editable with Cmd+S save, staged sections stay read-only.

Test plan

  • Open an unstaged changed file from Source Control → verify right side is editable
  • Edit the right side and press Cmd+S → verify file saves to disk
  • Verify dirty indicator (dot on tab) appears when editing, clears on save
  • Open a staged changed file → verify it remains read-only
  • Open "View All Changes" → verify unstaged sections are editable, staged are not
  • Edit in "View All Changes", Cmd+S → verify the specific file saves correctly
  • Switch tabs away and back to an edited diff → verify edits are preserved

🤖 Generated with Claude Code

The modified (right) side of diff views is now editable for unstaged files,
matching the behavior of VS Code and Zed. Staged diffs remain read-only.
Supports Cmd+S to save, dirty state tracking, and works in both single-file
and combined ("View All Changes") diff views.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nwparker
nwparker merged commit 3d4ed41 into main Mar 26, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant