|
|
@ -2519,7 +2519,7 @@ async fn make_format_callback(
|
|
|
|
write: Option<(Option<PathBuf>, bool)>,
|
|
|
|
write: Option<(Option<PathBuf>, bool)>,
|
|
|
|
) -> anyhow::Result<job::Callback> {
|
|
|
|
) -> anyhow::Result<job::Callback> {
|
|
|
|
let format = format.await?;
|
|
|
|
let format = format.await?;
|
|
|
|
let call: job::Callback = Callback::EditorCompositor(Box::new(move |editor, _compositor| {
|
|
|
|
let call: job::Callback = Callback::Editor(Box::new(move |editor| {
|
|
|
|
if !editor.documents.contains_key(&doc_id) {
|
|
|
|
if !editor.documents.contains_key(&doc_id) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2527,7 +2527,6 @@ async fn make_format_callback(
|
|
|
|
let scrolloff = editor.config().scrolloff;
|
|
|
|
let scrolloff = editor.config().scrolloff;
|
|
|
|
let doc = doc_mut!(editor, &doc_id);
|
|
|
|
let doc = doc_mut!(editor, &doc_id);
|
|
|
|
let view = view_mut!(editor);
|
|
|
|
let view = view_mut!(editor);
|
|
|
|
let loader = editor.syn_loader.clone();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if doc.version() == doc_version {
|
|
|
|
if doc.version() == doc_version {
|
|
|
|
apply_transaction(&format, doc, view);
|
|
|
|
apply_transaction(&format, doc, view);
|
|
|
@ -2536,14 +2535,8 @@ async fn make_format_callback(
|
|
|
|
view.ensure_cursor_in_view(doc, scrolloff);
|
|
|
|
view.ensure_cursor_in_view(doc, scrolloff);
|
|
|
|
|
|
|
|
|
|
|
|
if let Some((path, force)) = write {
|
|
|
|
if let Some((path, force)) = write {
|
|
|
|
let refresh_lang = path.is_some();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Err(err) = doc.save(path, force) {
|
|
|
|
if let Err(err) = doc.save(path, force) {
|
|
|
|
editor.set_error(format!("Error saving: {}", err));
|
|
|
|
editor.set_error(format!("Error saving: {}", err));
|
|
|
|
} else if refresh_lang {
|
|
|
|
|
|
|
|
let id = doc.id();
|
|
|
|
|
|
|
|
doc.detect_language(loader);
|
|
|
|
|
|
|
|
let _ = editor.refresh_language_server(id);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|