Tweak structure of Project::on_lsp_progress so it can be auto-formatted

Previously, rustfmt seems to have given up on formatting this method.
This commit is contained in:
Max Brunsfeld 2022-04-06 16:35:58 -07:00
parent f9e1b4de96
commit 8f38ac8270

View file

@ -1633,93 +1633,84 @@ impl Project {
return; return;
} }
}; };
let progress = match progress.value {
match progress.value { lsp::ProgressParamsValue::WorkDone(value) => value,
lsp::ProgressParamsValue::WorkDone(progress) => match progress { };
lsp::WorkDoneProgress::Begin(_) => { let language_server_status =
let language_server_status = if let Some(status) = self.language_server_statuses.get_mut(&server_id) {
if let Some(status) = self.language_server_statuses.get_mut(&server_id) { status
status } else {
} else { return;
return; };
}; match progress {
lsp::WorkDoneProgress::Begin(_) => {
if Some(token.as_str()) == disk_based_diagnostics_progress_token { if Some(token.as_str()) == disk_based_diagnostics_progress_token {
language_server_status.pending_diagnostic_updates += 1; language_server_status.pending_diagnostic_updates += 1;
if language_server_status.pending_diagnostic_updates == 1 { if language_server_status.pending_diagnostic_updates == 1 {
self.disk_based_diagnostics_started(cx); self.disk_based_diagnostics_started(cx);
self.broadcast_language_server_update(
server_id,
proto::update_language_server::Variant::DiskBasedDiagnosticsUpdating(
proto::LspDiskBasedDiagnosticsUpdating {},
),
);
}
} else {
self.on_lsp_work_start(server_id, token.clone(), cx);
self.broadcast_language_server_update( self.broadcast_language_server_update(
server_id, server_id,
proto::update_language_server::Variant::WorkStart( proto::update_language_server::Variant::DiskBasedDiagnosticsUpdating(
proto::LspWorkStart { token }, proto::LspDiskBasedDiagnosticsUpdating {},
), ),
); );
} }
} else {
self.on_lsp_work_start(server_id, token.clone(), cx);
self.broadcast_language_server_update(
server_id,
proto::update_language_server::Variant::WorkStart(proto::LspWorkStart {
token,
}),
);
} }
lsp::WorkDoneProgress::Report(report) => { }
if Some(token.as_str()) != disk_based_diagnostics_progress_token { lsp::WorkDoneProgress::Report(report) => {
self.on_lsp_work_progress( if Some(token.as_str()) != disk_based_diagnostics_progress_token {
server_id, self.on_lsp_work_progress(
token.clone(), server_id,
LanguageServerProgress { token.clone(),
message: report.message.clone(), LanguageServerProgress {
percentage: report.percentage.map(|p| p as usize), message: report.message.clone(),
last_update_at: Instant::now(), percentage: report.percentage.map(|p| p as usize),
}, last_update_at: Instant::now(),
cx, },
); cx,
self.broadcast_language_server_update( );
server_id, self.broadcast_language_server_update(
proto::update_language_server::Variant::WorkProgress( server_id,
proto::LspWorkProgress { proto::update_language_server::Variant::WorkProgress(
token, proto::LspWorkProgress {
message: report.message,
percentage: report.percentage.map(|p| p as u32),
},
),
);
}
}
lsp::WorkDoneProgress::End(_) => {
if Some(token.as_str()) == disk_based_diagnostics_progress_token {
let language_server_status = if let Some(status) =
self.language_server_statuses.get_mut(&server_id)
{
status
} else {
return;
};
language_server_status.pending_diagnostic_updates -= 1;
if language_server_status.pending_diagnostic_updates == 0 {
self.disk_based_diagnostics_finished(cx);
self.broadcast_language_server_update(
server_id,
proto::update_language_server::Variant::DiskBasedDiagnosticsUpdated(
proto::LspDiskBasedDiagnosticsUpdated {},
),
);
}
} else {
self.on_lsp_work_end(server_id, token.clone(), cx);
self.broadcast_language_server_update(
server_id,
proto::update_language_server::Variant::WorkEnd(proto::LspWorkEnd {
token, token,
}), message: report.message,
percentage: report.percentage.map(|p| p as u32),
},
),
);
}
}
lsp::WorkDoneProgress::End(_) => {
if Some(token.as_str()) == disk_based_diagnostics_progress_token {
language_server_status.pending_diagnostic_updates -= 1;
if language_server_status.pending_diagnostic_updates == 0 {
self.disk_based_diagnostics_finished(cx);
self.broadcast_language_server_update(
server_id,
proto::update_language_server::Variant::DiskBasedDiagnosticsUpdated(
proto::LspDiskBasedDiagnosticsUpdated {},
),
); );
} }
} else {
self.on_lsp_work_end(server_id, token.clone(), cx);
self.broadcast_language_server_update(
server_id,
proto::update_language_server::Variant::WorkEnd(proto::LspWorkEnd {
token,
}),
);
} }
}, }
} }
} }