Optimistically update hunk states when staging and unstaging hunks (#25687)
This PR adds an optimistic update when staging or unstaging diff hunks. In the process, I've also refactored the logic for staging and unstaging hunks, to consolidate more of it in the `buffer_diff` crate. I've also changed the way that we treat untracked files. Previously, we maintained an empty diff for them, so as not to show unwanted entire-file diff hunks in a regular editor. But then in the project diff view, we had to account for this, and replace these empty diffs with entire-file diffs. This form of state management made it more difficult to store the pending hunks, so now we always use the same `BufferDiff`/`BufferDiffSnapshot` for untracked files (with a single hunk spanning the entire buffer), but we just have a special case in regular buffers, that avoids showing that entire-file hunk. * [x] Avoid creating a long queue of `set_index` operations when staging/unstaging rapidly * [x] Keep pending hunks when diff is recalculated without base text changes * [x] Be optimistic even when staging the single hunk in added/deleted files * Testing Release Notes: - N/A --------- Co-authored-by: Cole Miller <m@cole-miller.net>
This commit is contained in:
parent
9d8a163f5b
commit
0c2bbb3aa9
14 changed files with 756 additions and 600 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2076,6 +2076,7 @@ name = "buffer_diff"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clock",
|
||||
"ctor",
|
||||
"env_logger 0.11.6",
|
||||
"futures 0.3.31",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue