on master help sign in
Satisfy clippy.
commitffa2f2590bc679b3cf8529e9578860ad05b78148 authorJoe Neeman <joeneeman@gmail.com> dateMon 28 Jun 2021, 08:00 (5 years ago) parentd64d75e
3 files changed+22−25
helix-term/src/application.rs+1−1 helix-term/src/commands.rs+17−20 helix-term/src/job.rs+4−4
helix-term/src/application.rs+1−1
@@ -167,7 +167,7 @@ impl Application {
167167 }
168168 self.render();
169169 }
170− Some(callback) = self.jobs.next() => {
170+ Some(callback) = self.jobs.next_job() => {
171171 self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
172172 self.render();
173173 }
helix-term/src/commands.rs+17−20
@@ -1917,31 +1917,28 @@ fn append_to_line(cx: &mut Context) {
19171917
19181918// Creates an LspCallback that waits for formatting changes to be computed. When they're done,
19191919// it applies them, but only if the doc hasn't changed.
1920−fn make_format_callback(
1920+async fn make_format_callback(
19211921 doc_id: DocumentId,
19221922 doc_version: i32,
19231923 set_unmodified: bool,
19241924 format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
1925−) -> impl Future<Output = anyhow::Result<job::Callback>> {
1926− async move {
1927− let format = format.await;
1928− let call: job::Callback =
1929− Box::new(move |editor: &mut Editor, compositor: &mut Compositor| {
1930− let view_id = view!(editor).id;
1931− if let Some(doc) = editor.document_mut(doc_id) {
1932− if doc.version() == doc_version {
1933− doc.apply(&Transaction::from(format), view_id);
1934− doc.append_changes_to_history(view_id);
1935− if set_unmodified {
1936− doc.reset_modified();
1937− }
1938− } else {
1939− log::info!("discarded formatting changes because the document changed");
1940− }
1925+) -> anyhow::Result<job::Callback> {
1926+ let format = format.await;
1927+ let call: job::Callback = Box::new(move |editor: &mut Editor, compositor: &mut Compositor| {
1928+ let view_id = view!(editor).id;
1929+ if let Some(doc) = editor.document_mut(doc_id) {
1930+ if doc.version() == doc_version {
1931+ doc.apply(&Transaction::from(format), view_id);
1932+ doc.append_changes_to_history(view_id);
1933+ if set_unmodified {
1934+ doc.reset_modified();
19411935 }
1942− });
1943− Ok(call)
1944− }
1936+ } else {
1937+ log::info!("discarded formatting changes because the document changed");
1938+ }
1939+ }
1940+ });
1941+ Ok(call)
19451942}
19461943
19471944enum Open {
helix-term/src/job.rs+4−4
@@ -33,7 +33,7 @@ impl Job {
3333 f: F,
3434 ) -> Job {
3535 Job {
36− future: f.map(|r| r.map(|x| Some(x))).boxed(),
36+ future: f.map(|r| r.map(Some)).boxed(),
3737 wait: false,
3838 }
3939 }
@@ -77,9 +77,9 @@ impl Jobs {
7777 }
7878 }
7979
80− pub fn next<'a>(
81− &'a mut self,
82− ) -> impl Future<Output = Option<anyhow::Result<Option<Callback>>>> + 'a {
80+ pub fn next_job(
81+ &mut self,
82+ ) -> impl Future<Output = Option<anyhow::Result<Option<Callback>>>> + '_ {
8383 future::select(self.futures.next(), self.wait_futures.next())
8484 .map(|either| either.factor_first().0)
8585 }