Editable diffs in FilePatchItems #1720
Description
Once #1712 lands, the FilePatchItem
will be rendering diffs with an Atom TextEditor
component, but it will be in read-only mode. Let's let users edit diffs directly from the diff view! This saves you the trouble of needing to toggle to an editor and back again when you notice typos, console.log()
statements, or .only()
tests when reviewing unstaged or staged changes.
Editing a diff's contents should mark the item as "modified" and be treated by Atom like an unsaved text editor: it should cancel shutdown with a prompt to save and so on. Saving the item should apply the modifications to the underlying resource.
Saving edits to a diff within an "Unstaged changes" file patch item modifies the underlying file in your working copy, as though you'd pressed cmd-O
and edited the file there.
Saving edits to a diff within a "Staged changes" file patch item modifies the staged index entry for this file. This leaves the file on disk unchanged, but the saved modifications will be applied to the file that ultimately becomes a part of the next commit.
Editing addition or unchanged lines is straightforward: the edits are written through to the equivalent locations in the "new" file. When editing a removal, though, the removed line needs to "split" into an addition and a removal with the edit and the cursor placed on the addition line.