Preserve cursor position when resetting excerpts (#27850)

Release Notes:

- N/A

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Antonio Scandurra
2025-04-01 16:55:10 +00:00
committed by GitHub
co-authored by Nathan Sobo Conrad Irwin
parent f859b328f0
commit 76871056f5
19 changed files with 299 additions and 617 deletions
+6 -6
View File
@@ -51,7 +51,7 @@ struct RecalculateDiff {
struct BranchBufferSemanticsProvider(Rc<dyn SemanticsProvider>);
impl ProposedChangesEditor {
pub fn new<T: ToOffset>(
pub fn new<T: Clone + ToOffset>(
title: impl Into<SharedString>,
locations: Vec<ProposedChangeLocation<T>>,
project: Option<Entity<Project>>,
@@ -140,7 +140,7 @@ impl ProposedChangesEditor {
cx.notify();
}
pub fn reset_locations<T: ToOffset>(
pub fn reset_locations<T: Clone + ToOffset>(
&mut self,
locations: Vec<ProposedChangeLocation<T>>,
window: &mut Window,
@@ -202,10 +202,10 @@ impl ProposedChangesEditor {
self.multibuffer.update(cx, |multibuffer, cx| {
multibuffer.push_excerpts(
branch_buffer,
location.ranges.into_iter().map(|range| ExcerptRange {
context: range,
primary: None,
}),
location
.ranges
.into_iter()
.map(|range| ExcerptRange::new(range)),
cx,
);
});