Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions crates/editor/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ pub struct SplittableEditor {
/// True when the current width is below the minimum threshold for split
/// mode, regardless of the current diff view style setting.
too_narrow_for_split: bool,
delegate_stage_and_restore: bool,
last_width: Option<Pixels>,
_subscriptions: Vec<Subscription>,
}
Expand Down Expand Up @@ -471,6 +472,13 @@ impl SplittableEditor {
});
}

pub fn set_delegate_stage_and_restore(&mut self, delegate: bool, cx: &mut Context<Self>) {
self.delegate_stage_and_restore = delegate;
self.update_editors(cx, |editor, _cx| {
editor.set_delegate_stage_and_restore(delegate);
});
}

pub fn set_render_diff_hunks_as_unstaged(&self, cx: &mut Context<Self>) {
self.update_editors(cx, |editor, cx| {
editor.set_render_diff_hunks_as_unstaged(true, cx);
Expand Down Expand Up @@ -583,6 +591,7 @@ impl SplittableEditor {
split_state,
searched_side: None,
too_narrow_for_split: false,
delegate_stage_and_restore: false,
last_width: None,
_subscriptions: subscriptions,
}
Expand Down Expand Up @@ -666,6 +675,10 @@ impl SplittableEditor {
}
}
EditorEvent::StageOrUnstageRequested { stage, hunks } => {
if this.delegate_stage_and_restore {
cx.emit(event.clone());
return;
}
if this.lhs.is_some() {
let translated = translate_lhs_hunks_to_rhs(hunks, this, cx);
if !translated.is_empty() {
Expand All @@ -680,6 +693,10 @@ impl SplittableEditor {
}
}
EditorEvent::RestoreRequested { hunks } => {
if this.delegate_stage_and_restore {
cx.emit(event.clone());
return;
}
if this.lhs.is_some() {
let translated = translate_lhs_hunks_to_rhs(hunks, this, cx);
if !translated.is_empty() {
Expand Down
Loading
Loading