-
Notifications
You must be signed in to change notification settings - Fork 395
Conversation
lib/discard-changes-in-buffer.js
Outdated
removedCount++; | ||
} else { | ||
// eslint-disable-next-line no-console | ||
console.error(buffer.lineForRow(row) + ' does not match ' + line.text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 ?
... in order to minimize accidentally selecting it per #481 (comment)
from some adhoc testing, I found a edge case.
Expected: Shouldn't have the ability to Actual: |
@ungb thanks for testing and bringing up this edge case! This one's tricky because in theory we can actually allow people to undo their last discard even if the file has been changed since the discard. One thing to keep in mind is that the text buffer's undo history and the We can in theory undo a discard even after the file has been modified by applying a patch that has the discarded lines to working directory version of the file. If the discarded lines are in a different part of the file than the new modifications then the patch should apply cleanly without conflicts. I say "in theory" because we haven't yet implemented a version of this feature that allows users to undo their last discard if the file has been modified since the discard. This was for the sake of shipping something quick and simple up front, but there's certainly room for us to iterate and make the |
Fixes #50.
Fixes #481.
This PR implements discarding hunk lines via a
Discard Selection
context menu option and allows users to undo discard actions. This option is in a separate context menu section to reduce the possibility of accidentally selecting it, per #481 (comment).You can undo discards via the
Undo Last Discard
button (see below), keybindingcmd-z
, or commandgithub:undo-last-file-diff-discard
.The undo action will fail if the text buffer is modified, or if the file has been changed since the discard action.
Additionally, this PR introduces a new file diff header bar that displays the corresponding file name and staging status, and has buttons for opening the file in an editor and viewing the corresponding staged/unstaged version of the file if one exists.
TODO: