aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-11-30 03:59:19 +0000
committerBlaž Hrastnik2021-12-01 03:57:22 +0000
commitd562e13e1f875b1f5675ddc7ac6766a04228caaa (patch)
tree268ce2eb96fe3ac9d5ad68d41000d3d8d3a12abd /helix-term
parent3e15aead4adc5139417230d15b38112cdc4f7043 (diff)
minor: Use anchor::ensure in some cases
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/commands.rs10
1 files changed, 3 insertions, 7 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 0a2ecf9c..f938b719 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -24,7 +24,7 @@ use helix_view::{
Document, DocumentId, Editor, ViewId,
};
-use anyhow::{anyhow, bail, Context as _};
+use anyhow::{anyhow, bail, ensure, Context as _};
use helix_lsp::{
block_on, lsp,
util::{lsp_pos_to_pos, lsp_range_to_range, pos_to_lsp_pos, range_to_lsp_range},
@@ -2550,9 +2550,7 @@ mod cmd {
args: &[&str],
_event: PromptEvent,
) -> anyhow::Result<()> {
- if args.is_empty() {
- bail!("Line number required");
- }
+ ensure!(!args.is_empty(), "Line number required");
let line = args[0].parse::<usize>()?;
@@ -5553,9 +5551,7 @@ fn shell_impl(
) -> anyhow::Result<(Tendril, bool)> {
use std::io::Write;
use std::process::{Command, Stdio};
- if shell.is_empty() {
- bail!("No shell set");
- }
+ ensure!(!shell.is_empty(), "No shell set");
let mut process = match Command::new(&shell[0])
.args(&shell[1..])