Clear pending staged/unstaged diff hunks hunks when writing to the git index fails (#26173)

Release Notes:

- Git Beta: Fixed a bug where discarding a hunk in the project diff view
performed two concurrent saves of the buffer.
- Git Beta: Fixed an issue where diff hunks appeared in the wrong state
after failing to write to the git index.
This commit is contained in:
Max Brunsfeld 2025-03-05 18:45:09 -08:00 committed by GitHub
parent d3c68650c0
commit 314ad5dd5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 534 additions and 143 deletions

View file

@ -70,6 +70,10 @@ impl<K: Clone + Ord, V: Clone> TreeMap<K, V> {
self.0.insert_or_replace(MapEntry { key, value }, &());
}
pub fn clear(&mut self) {
self.0 = SumTree::default();
}
pub fn remove(&mut self, key: &K) -> Option<V> {
let mut removed = None;
let mut cursor = self.0.cursor::<MapKeyRef<'_, K>>(&());
@ -157,6 +161,14 @@ impl<K: Clone + Ord, V: Clone> TreeMap<K, V> {
self.0.iter().map(|entry| &entry.value)
}
pub fn first(&self) -> Option<(&K, &V)> {
self.0.first().map(|entry| (&entry.key, &entry.value))
}
pub fn last(&self) -> Option<(&K, &V)> {
self.0.last().map(|entry| (&entry.key, &entry.value))
}
pub fn insert_tree(&mut self, other: TreeMap<K, V>) {
let edits = other
.iter()