@@ -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 {