Refold updated patch only if the patch was already folded (#19462)
Release Notes: - N/A
This commit is contained in:
parent
781fff220c
commit
e8207288e5
1 changed files with 10 additions and 2 deletions
|
@ -2219,6 +2219,7 @@ impl ContextEditor {
|
||||||
merge_adjacent: false,
|
merge_adjacent: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let should_refold;
|
||||||
if let Some(state) = self.patches.get_mut(&range) {
|
if let Some(state) = self.patches.get_mut(&range) {
|
||||||
replaced_blocks.insert(state.footer_block_id, render_block);
|
replaced_blocks.insert(state.footer_block_id, render_block);
|
||||||
if let Some(editor_state) = &state.editor {
|
if let Some(editor_state) = &state.editor {
|
||||||
|
@ -2233,6 +2234,9 @@ impl ContextEditor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
should_refold =
|
||||||
|
snapshot.intersects_fold(patch_start.to_offset(&snapshot.buffer_snapshot));
|
||||||
} else {
|
} else {
|
||||||
let block_ids = editor.insert_blocks(
|
let block_ids = editor.insert_blocks(
|
||||||
[BlockProperties {
|
[BlockProperties {
|
||||||
|
@ -2266,11 +2270,15 @@ impl ContextEditor {
|
||||||
update_task: None,
|
update_task: None,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
should_refold = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if should_refold {
|
||||||
editor.unfold_ranges([patch_start..patch_end], true, false, cx);
|
editor.unfold_ranges([patch_start..patch_end], true, false, cx);
|
||||||
editor.fold_ranges([(patch_start..patch_end, header_placeholder)], false, cx);
|
editor.fold_ranges([(patch_start..patch_end, header_placeholder)], false, cx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
editor.remove_creases(removed_crease_ids, cx);
|
editor.remove_creases(removed_crease_ids, cx);
|
||||||
editor.remove_blocks(removed_block_ids, None, cx);
|
editor.remove_blocks(removed_block_ids, None, cx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue