on master help sign in
Satisfy clippy.
ffa2f25Joe Neeman
helix-term/src/application.rs+1−1
@@ -167,7 +167,7 @@ impl Application {
167 }
167 }
168 self.render();
168 self.render();
169 }
169 }
170− Some(callback) = self.jobs.next() => {
170+ Some(callback) = self.jobs.next_job() => {
171 self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
171 self.jobs.handle_callback(&mut self.editor, &mut self.compositor, callback);
172 self.render();
172 self.render();
173 }
173 }
helix-term/src/commands.rs+17−20
@@ -1917,31 +1917,28 @@ fn append_to_line(cx: &mut Context) {
1917
1917
1918// Creates an LspCallback that waits for formatting changes to be computed. When they're done,
1918// Creates an LspCallback that waits for formatting changes to be computed. When they're done,
1919// it applies them, but only if the doc hasn't changed.
1919// it applies them, but only if the doc hasn't changed.
1920−fn make_format_callback(
1920+async fn make_format_callback(
1921 doc_id: DocumentId,
1921 doc_id: DocumentId,
1922 doc_version: i32,
1922 doc_version: i32,
1923 set_unmodified: bool,
1923 set_unmodified: bool,
1924 format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
1924 format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
1925−) -> impl Future<Output = anyhow::Result<job::Callback>> {
1925+) -> anyhow::Result<job::Callback> {
1926− async move {
1927− let format = format.await;
1926+ let format = format.await;
1928− let call: job::Callback =
1929− Box::new(move |editor: &mut Editor, compositor: &mut Compositor| {
1927+ let call: job::Callback = Box::new(move |editor: &mut Editor, compositor: &mut Compositor| {
1930− let view_id = view!(editor).id;
1928+ let view_id = view!(editor).id;
1931− if let Some(doc) = editor.document_mut(doc_id) {
1929+ if let Some(doc) = editor.document_mut(doc_id) {
1932− if doc.version() == doc_version {
1930+ if doc.version() == doc_version {
1933− doc.apply(&Transaction::from(format), view_id);
1931+ doc.apply(&Transaction::from(format), view_id);
1934− doc.append_changes_to_history(view_id);
1932+ doc.append_changes_to_history(view_id);
1935− if set_unmodified {
1933+ if set_unmodified {
1936− doc.reset_modified();
1934+ doc.reset_modified();
1937− }
1938− } else {
1939− log::info!("discarded formatting changes because the document changed");
1940− }
1941 }
1935 }
1942− });
1936+ } else {
1937+ log::info!("discarded formatting changes because the document changed");
1938+ }
1939+ }
1940+ });
1943− Ok(call)
1941+ Ok(call)
1944− }
1945}
1942}
1946
1943
1947enum Open {
1944enum Open {
helix-term/src/job.rs+4−4
@@ -33,7 +33,7 @@ impl Job {
33 f: F,
33 f: F,
34 ) -> Job {
34 ) -> Job {
35 Job {
35 Job {
36− future: f.map(|r| r.map(|x| Some(x))).boxed(),
36+ future: f.map(|r| r.map(Some)).boxed(),
37 wait: false,
37 wait: false,
38 }
38 }
39 }
39 }
@@ -77,9 +77,9 @@ impl Jobs {
77 }
77 }
78 }
78 }
79
79
80− pub fn next<'a>(
80+ pub fn next_job(
81− &'a mut self,
81+ &mut self,
82− ) -> impl Future<Output = Option<anyhow::Result<Option<Callback>>>> + 'a {
82+ ) -> impl Future<Output = Option<anyhow::Result<Option<Callback>>>> + '_ {
83 future::select(self.futures.next(), self.wait_futures.next())
83 future::select(self.futures.next(), self.wait_futures.next())
84 .map(|either| either.factor_first().0)
84 .map(|either| either.factor_first().0)
85 }
85 }