Compare commits

...

2 Commits

Author SHA1 Message Date
Jakub Konka
370a418fb7 git: Dedup paths needing status update in the job 2025-11-26 13:28:57 +01:00
Jakub Konka
78879876c1 git: Log job queue 2025-11-26 13:28:05 +01:00
2 changed files with 42 additions and 10 deletions

View File

@@ -1850,7 +1850,7 @@ impl Editor {
.cursor_pointer() .cursor_pointer()
.child("") .child("")
.on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation()) .on_mouse_down(MouseButton::Left, |_, _, cx| cx.stop_propagation())
.on_click(move |_, _window, cx| { .on_click(move |_, _win, cx| {
editor editor
.update(cx, |editor, cx| { .update(cx, |editor, cx| {
editor.unfold_ranges( editor.unfold_ranges(
@@ -6605,7 +6605,7 @@ impl Editor {
.when(show_tooltip, |this| { .when(show_tooltip, |this| {
this.tooltip({ this.tooltip({
let focus_handle = self.focus_handle.clone(); let focus_handle = self.focus_handle.clone();
move |_window, cx| { move |_win, cx| {
Tooltip::for_action_in( Tooltip::for_action_in(
"Toggle Code Actions", "Toggle Code Actions",
&ToggleCodeActions { &ToggleCodeActions {
@@ -7929,7 +7929,7 @@ impl Editor {
fn update_visible_edit_prediction( fn update_visible_edit_prediction(
&mut self, &mut self,
_window: &mut Window, _win: &mut Window,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Option<()> { ) -> Option<()> {
if DisableAiSettings::get_global(cx).disable_ai { if DisableAiSettings::get_global(cx).disable_ai {
@@ -8308,7 +8308,7 @@ impl Editor {
this.entry(msg, None, { this.entry(msg, None, {
let weak_editor = weak_editor.clone(); let weak_editor = weak_editor.clone();
let breakpoint = breakpoint.clone(); let breakpoint = breakpoint.clone();
move |_window, cx| { move |_win, cx| {
weak_editor weak_editor
.update(cx, |this, cx| { .update(cx, |this, cx| {
this.edit_breakpoint_at_anchor( this.edit_breakpoint_at_anchor(
@@ -25434,7 +25434,7 @@ fn render_diff_hunk_controls(
Button::new(("restore", row as u64), "Restore") Button::new(("restore", row as u64), "Restore")
.tooltip({ .tooltip({
let focus_handle = editor.focus_handle(cx); let focus_handle = editor.focus_handle(cx);
move |_window, cx| { move |_win, cx| {
Tooltip::for_action_in("Restore Hunk", &::git::Restore, &focus_handle, cx) Tooltip::for_action_in("Restore Hunk", &::git::Restore, &focus_handle, cx)
} }
}) })
@@ -25460,7 +25460,7 @@ fn render_diff_hunk_controls(
// .disabled(!has_multiple_hunks) // .disabled(!has_multiple_hunks)
.tooltip({ .tooltip({
let focus_handle = editor.focus_handle(cx); let focus_handle = editor.focus_handle(cx);
move |_window, cx| { move |_win, cx| {
Tooltip::for_action_in("Next Hunk", &GoToHunk, &focus_handle, cx) Tooltip::for_action_in("Next Hunk", &GoToHunk, &focus_handle, cx)
} }
}) })
@@ -25490,7 +25490,7 @@ fn render_diff_hunk_controls(
// .disabled(!has_multiple_hunks) // .disabled(!has_multiple_hunks)
.tooltip({ .tooltip({
let focus_handle = editor.focus_handle(cx); let focus_handle = editor.focus_handle(cx);
move |_window, cx| { move |_win, cx| {
Tooltip::for_action_in( Tooltip::for_action_in(
"Previous Hunk", "Previous Hunk",
&GoToPreviousHunk, &GoToPreviousHunk,

View File

@@ -343,7 +343,13 @@ pub struct GitJob {
key: Option<GitJobKey>, key: Option<GitJobKey>,
} }
#[derive(PartialEq, Eq)] impl std::fmt::Debug for GitJob {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "GitJob {{ {:?} }}", self.key)
}
}
#[derive(Debug, PartialEq, Eq)]
enum GitJobKey { enum GitJobKey {
WriteIndex(Vec<RepoPath>), WriteIndex(Vec<RepoPath>),
ReloadBufferDiffBases, ReloadBufferDiffBases,
@@ -5213,22 +5219,29 @@ impl Repository {
}; };
let mut jobs = VecDeque::new(); let mut jobs = VecDeque::new();
loop { loop {
println!(" Current job queue: {:?}", jobs);
while let Ok(Some(next_job)) = job_rx.try_next() { while let Ok(Some(next_job)) = job_rx.try_next() {
println!(" >>> pushing new job: {next_job:?}");
jobs.push_back(next_job); jobs.push_back(next_job);
} }
if let Some(job) = jobs.pop_front() { if let Some(job) = jobs.pop_front() {
println!(" >>> popping front: {job:?}");
if let Some(current_key) = &job.key if let Some(current_key) = &job.key
&& jobs && jobs
.iter() .iter()
.any(|other_job| other_job.key.as_ref() == Some(current_key)) .any(|other_job| other_job.key.as_ref() == Some(current_key))
{ {
println!(" >>> SKIPPING");
continue; continue;
} }
println!(" >>> RUNNING!");
(job.job)(state.clone(), cx).await; (job.job)(state.clone(), cx).await;
} else if let Some(job) = job_rx.next().await { } else if let Some(job) = job_rx.next().await {
println!(" >>> blocking for new job: {job:?}");
jobs.push_back(job); jobs.push_back(job);
} else { } else {
// TODO: as far as I understand, this prong will never be reached
break; break;
} }
} }
@@ -5372,13 +5385,17 @@ impl Repository {
updates_tx: Option<mpsc::UnboundedSender<DownstreamUpdate>>, updates_tx: Option<mpsc::UnboundedSender<DownstreamUpdate>>,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) { ) {
self.paths_needing_status_update.extend(paths); println!("paths_neeeding_status_update: {paths:?}");
// self.paths_needing_status_update.extend(paths.clone());
let this = cx.weak_entity(); let this = cx.weak_entity();
let _ = self.send_keyed_job( let res = self.send_keyed_job(
Some(GitJobKey::RefreshStatuses), Some(GitJobKey::RefreshStatuses),
None, None,
|state, mut cx| async move { |state, mut cx| async move {
this.update(&mut cx, |this, _| {
this.paths_needing_status_update.extend(paths);
})?;
let (prev_snapshot, mut changed_paths) = this.update(&mut cx, |this, _| { let (prev_snapshot, mut changed_paths) = this.update(&mut cx, |this, _| {
( (
this.snapshot.clone(), this.snapshot.clone(),
@@ -5450,6 +5467,21 @@ impl Repository {
}) })
}, },
); );
cx.spawn(async move |this, cx| match res.await {
Ok(res) => {
let _ = res;
}
Err(Canceled) => {
println!(
"skipped!!! this.paths_needing_status_update.len() = {:?}",
this.update(cx, |this, _cx| {
this.paths_needing_status_update.iter().count()
})
);
}
})
.detach();
} }
/// currently running git command and when it started /// currently running git command and when it started