aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorA-Walrus2022-08-08 19:04:41 +0000
committerBlaž Hrastnik2022-09-10 13:23:38 +0000
commite8add6f46d0f208c96407151276a985dd34fc93f (patch)
tree1370a1025e543b6e0019946d699217c4b504d8a2 /helix-term/src
parentcc47d3fb9d048b7fe2546409a492f27f6199adf5 (diff)
Add error handling to set language command
If you type a nonexistant language an appropriate message will show, and the language won't be changed.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands/typed.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index f005d9bf..127eea0d 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -1253,7 +1253,16 @@ fn language(
}
let doc = doc_mut!(cx.editor);
- doc.set_language_by_language_id(&args[0], cx.editor.syn_loader.clone());
+
+ let loader = cx.editor.syn_loader.clone();
+ if args[0] == "text" {
+ doc.set_language(None, Some(loader))
+ } else {
+ let ok = doc.set_language_by_language_id(&args[0], loader);
+ if !ok {
+ anyhow::bail!("invalid language: {}", args[0]);
+ }
+ }
doc.detect_indent_and_line_ending();
let id = doc.id();