on master help sign in
minor: Use anchor::ensure in some cases
commitd562e13e1f875b1f5675ddc7ac6766a04228caaa authorBlaž Hrastnik <blaz@mxxn.io> dateTue 30 Nov 2021, 12:59 (5 years ago) parent3e15aea
1 file changed+3−7
helix-term/src/commands.rs+3−7
helix-term/src/commands.rs+3−7
@@ -24,7 +24,7 @@ use helix_view::{
2424 Document, DocumentId, Editor, ViewId,
2525};
2626
27−use anyhow::{anyhow, bail, Context as _};
27+use anyhow::{anyhow, bail, ensure, Context as _};
2828use helix_lsp::{
2929 block_on, lsp,
3030 util::{lsp_pos_to_pos, lsp_range_to_range, pos_to_lsp_pos, range_to_lsp_range},
@@ -2550,9 +2550,7 @@ mod cmd {
25502550 args: &[&str],
25512551 _event: PromptEvent,
25522552 ) -> anyhow::Result<()> {
2553− if args.is_empty() {
2554− bail!("Line number required");
2555− }
2553+ ensure!(!args.is_empty(), "Line number required");
25562554
25572555 let line = args[0].parse::<usize>()?;
25582556
@@ -5553,9 +5551,7 @@ fn shell_impl(
55535551) -> anyhow::Result<(Tendril, bool)> {
55545552 use std::io::Write;
55555553 use std::process::{Command, Stdio};
5556− if shell.is_empty() {
5557− bail!("No shell set");
5558− }
5554+ ensure!(!shell.is_empty(), "No shell set");
55595555
55605556 let mut process = match Command::new(&shell[0])
55615557 .args(&shell[1..])