Compare commits

...

1 Commits

Author SHA1 Message Date
Max Brunsfeld
69bbcffcd9 🎨 Remove unnecessary title field from ProposedChangesEditor 2024-10-30 17:12:17 -07:00
3 changed files with 10 additions and 9 deletions

View File

@@ -2468,7 +2468,7 @@ impl ContextEditor {
let editor = cx.new_view(|cx| { let editor = cx.new_view(|cx| {
let editor = ProposedChangesEditor::new( let editor = ProposedChangesEditor::new(
patch.title.clone(), patch.title.clone().into(),
resolved_patch resolved_patch
.edit_groups .edit_groups
.iter() .iter()

View File

@@ -12394,7 +12394,7 @@ impl Editor {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
let proposed_changes_editor = cx.new_view(|cx| { let proposed_changes_editor = cx.new_view(|cx| {
ProposedChangesEditor::new( ProposedChangesEditor::new(
"Proposed changes", "Proposed changes".into(),
proposed_changes_buffers, proposed_changes_buffers,
self.project.clone(), self.project.clone(),
cx, cx,

View File

@@ -17,7 +17,6 @@ use workspace::{
pub struct ProposedChangesEditor { pub struct ProposedChangesEditor {
editor: View<Editor>, editor: View<Editor>,
multibuffer: Model<MultiBuffer>, multibuffer: Model<MultiBuffer>,
title: SharedString,
buffer_entries: Vec<BufferEntry>, buffer_entries: Vec<BufferEntry>,
_recalculate_diffs_task: Task<Option<()>>, _recalculate_diffs_task: Task<Option<()>>,
recalculate_diffs_tx: mpsc::UnboundedSender<RecalculateDiff>, recalculate_diffs_tx: mpsc::UnboundedSender<RecalculateDiff>,
@@ -51,12 +50,13 @@ struct BranchBufferSemanticsProvider(Rc<dyn SemanticsProvider>);
impl ProposedChangesEditor { impl ProposedChangesEditor {
pub fn new<T: ToOffset>( pub fn new<T: ToOffset>(
title: impl Into<SharedString>, title: String,
locations: Vec<ProposedChangeLocation<T>>, locations: Vec<ProposedChangeLocation<T>>,
project: Option<Model<Project>>, project: Option<Model<Project>>,
cx: &mut ViewContext<Self>, cx: &mut ViewContext<Self>,
) -> Self { ) -> Self {
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite)); let multibuffer =
cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite).with_title(title));
let (recalculate_diffs_tx, mut recalculate_diffs_rx) = mpsc::unbounded(); let (recalculate_diffs_tx, mut recalculate_diffs_rx) = mpsc::unbounded();
let mut this = Self { let mut this = Self {
editor: cx.new_view(|cx| { editor: cx.new_view(|cx| {
@@ -72,7 +72,6 @@ impl ProposedChangesEditor {
editor editor
}), }),
multibuffer, multibuffer,
title: title.into(),
buffer_entries: Vec::new(), buffer_entries: Vec::new(),
recalculate_diffs_tx, recalculate_diffs_tx,
_recalculate_diffs_task: cx.spawn(|_, mut cx| async move { _recalculate_diffs_task: cx.spawn(|_, mut cx| async move {
@@ -121,7 +120,9 @@ impl ProposedChangesEditor {
} }
pub fn set_title(&mut self, title: SharedString, cx: &mut ViewContext<Self>) { pub fn set_title(&mut self, title: SharedString, cx: &mut ViewContext<Self>) {
self.title = title; self.multibuffer.update(cx, |multibuffer, cx| {
multibuffer.set_title(title.into(), cx);
});
cx.notify(); cx.notify();
} }
@@ -254,8 +255,8 @@ impl Item for ProposedChangesEditor {
Some(Icon::new(IconName::Diff)) Some(Icon::new(IconName::Diff))
} }
fn tab_content_text(&self, _cx: &WindowContext) -> Option<SharedString> { fn tab_content_text(&self, cx: &WindowContext) -> Option<SharedString> {
Some(self.title.clone()) Some(self.multibuffer.read(cx).title(cx).to_string().into())
} }
fn as_searchable(&self, _: &View<Self>) -> Option<Box<dyn SearchableItemHandle>> { fn as_searchable(&self, _: &View<Self>) -> Option<Box<dyn SearchableItemHandle>> {