From 7a2afdc080e56eda48128b82ce77fce574f1f814 Mon Sep 17 00:00:00 2001 From: Tomasz Zurkowski Date: Wed, 4 Dec 2024 15:27:54 +0100 Subject: [PATCH] Show an error when formatter is not available (#12183) --- helix-term/src/commands/typed.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 3fd86ffdaf20..4e3946a3e1b2 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -456,13 +456,15 @@ fn format( } let (view, doc) = current!(cx.editor); - if let Some(format) = doc.format() { - let callback = make_format_callback(doc.id(), doc.version(), view.id, format, None); - cx.jobs.callback(callback); - } + let format = doc.format().context( + "A formatter isn't available, and no language server provides formatting capabilities", + )?; + let callback = make_format_callback(doc.id(), doc.version(), view.id, format, None); + cx.jobs.callback(callback); Ok(()) } + fn set_indent_style( cx: &mut compositor::Context, args: &[Cow],