mirror of
https://github.com/helix-editor/helix.git
synced 2025-01-18 21:17:08 +04:00
Add extra logging for external formatters and formatting errors
This should help debug formatting failures when using external formatters in the future. Previously we didn't log anything when an external formatter failed despite having a custom error type for it.
This commit is contained in:
parent
4c41c5250c
commit
69068770c8
@ -3438,14 +3438,19 @@ async fn make_format_callback(
|
|||||||
let doc = doc_mut!(editor, &doc_id);
|
let doc = doc_mut!(editor, &doc_id);
|
||||||
let view = view_mut!(editor, view_id);
|
let view = view_mut!(editor, view_id);
|
||||||
|
|
||||||
if let Ok(format) = format {
|
match format {
|
||||||
if doc.version() == doc_version {
|
Ok(format) => {
|
||||||
doc.apply(&format, view.id);
|
if doc.version() == doc_version {
|
||||||
doc.append_changes_to_history(view);
|
doc.apply(&format, view.id);
|
||||||
doc.detect_indent_and_line_ending();
|
doc.append_changes_to_history(view);
|
||||||
view.ensure_cursor_in_view(doc, scrolloff);
|
doc.detect_indent_and_line_ending();
|
||||||
} else {
|
view.ensure_cursor_in_view(doc, scrolloff);
|
||||||
log::info!("discarded formatting changes because the document changed");
|
} else {
|
||||||
|
log::info!("discarded formatting changes because the document changed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
log::info!("failed to format '{}': {err}", doc.display_name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -772,6 +772,11 @@ pub fn format(&self) -> Option<BoxFuture<'static, Result<Transaction, FormatterE
|
|||||||
))
|
))
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
log::debug!(
|
||||||
|
"formatting '{}' with command '{}', args {fmt_args:?}",
|
||||||
|
self.display_name(),
|
||||||
|
fmt_cmd.display(),
|
||||||
|
);
|
||||||
use std::process::Stdio;
|
use std::process::Stdio;
|
||||||
let text = self.text().clone();
|
let text = self.text().clone();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user