aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Neeman2021-06-28 13:00:44 +0000
committerBlaž Hrastnik2021-06-30 08:08:50 +0000
commitffa2f2590bc679b3cf8529e9578860ad05b78148 (patch)
treef7381603e7d998d3138351e07212834802bf90dc
parentd64d75e72434842f2cceff2c77a03efab5e7a0bc (diff)
Satisfy clippy.
-rw-r--r--helix-term/src/application.rs2
-rw-r--r--helix-term/src/commands.rs37
-rw-r--r--helix-term/src/job.rs8
3 files changed, 22 insertions, 25 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index c2ae4651..3d20e1b3 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -167,7 +167,7 @@ impl Application {
}
self.render();
}
- Some(callback) = self.jobs.next() => {
+ Some(callback) = self.jobs.next_job() => {
self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
self.render();
}
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 5dd539cc..5df52855 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -1917,31 +1917,28 @@ fn append_to_line(cx: &mut Context) {
// Creates an LspCallback that waits for formatting changes to be computed. When they're done,
// it applies them, but only if the doc hasn't changed.
-fn make_format_callback(
+async fn make_format_callback(
doc_id: DocumentId,
doc_version: i32,
set_unmodified: bool,
format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
-) -> impl Future<Output = anyhow::Result<job::Callback>> {
- async move {
- let format = format.await;
- let call: job::Callback =
- Box::new(move |editor: &mut Editor, compositor: &mut Compositor| {
- let view_id = view!(editor).id;
- if let Some(doc) = editor.document_mut(doc_id) {
- if doc.version() == doc_version {
- doc.apply(&Transaction::from(format), view_id);
- doc.append_changes_to_history(view_id);
- if set_unmodified {
- doc.reset_modified();
- }
- } else {
- log::info!("discarded formatting changes because the document changed");
- }
+) -> anyhow::Result<job::Callback> {
+ let format = format.await;
+ let call: job::Callback = Box::new(move |editor: &mut Editor, compositor: &mut Compositor| {
+ let view_id = view!(editor).id;
+ if let Some(doc) = editor.document_mut(doc_id) {
+ if doc.version() == doc_version {
+ doc.apply(&Transaction::from(format), view_id);
+ doc.append_changes_to_history(view_id);
+ if set_unmodified {
+ doc.reset_modified();
}
- });
- Ok(call)
- }
+ } else {
+ log::info!("discarded formatting changes because the document changed");
+ }
+ }
+ });
+ Ok(call)
}
enum Open {
diff --git a/helix-term/src/job.rs b/helix-term/src/job.rs
index fcecfbce..4b59c81c 100644
--- a/helix-term/src/job.rs
+++ b/helix-term/src/job.rs
@@ -33,7 +33,7 @@ impl Job {
f: F,
) -> Job {
Job {
- future: f.map(|r| r.map(|x| Some(x))).boxed(),
+ future: f.map(|r| r.map(Some)).boxed(),
wait: false,
}
}
@@ -77,9 +77,9 @@ impl Jobs {
}
}
- pub fn next<'a>(
- &'a mut self,
- ) -> impl Future<Output = Option<anyhow::Result<Option<Callback>>>> + 'a {
+ pub fn next_job(
+ &mut self,
+ ) -> impl Future<Output = Option<anyhow::Result<Option<Callback>>>> + '_ {
future::select(self.futures.next(), self.wait_futures.next())
.map(|either| either.factor_first().0)
}