Skip to content

Commit

Permalink
edit: return early if prereq is not met
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Nov 13, 2024
1 parent 20b2cbe commit e4af513
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/kamp/cmd/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use std::path::PathBuf;
use super::{Context, Error, Result};

pub(crate) fn edit(ctx: Context, focus: bool, files: Vec<String>) -> Result<bool> {
if focus && ctx.is_draft() {
return Err(anyhow::Error::msg("no client in context").into());
}
let mut buf = String::new();
let mut pair = [None; 2];
let mut coord = None;
Expand Down Expand Up @@ -57,8 +60,6 @@ pub(crate) fn edit(ctx: Context, focus: bool, files: Vec<String>) -> Result<bool
buf.push_str("\nfocus");
}
ctx.send(None, &buf).map(|_| is_scratch)
} else if focus {
Err(anyhow::Error::msg("no client in context").into())
} else {
// this one acts like attach
ctx.connect(&buf).map(|_| is_scratch)
Expand Down

0 comments on commit e4af513

Please sign in to comment.