Skip to content

Commit

Permalink
handle splits more elegantly
Browse files Browse the repository at this point in the history
  • Loading branch information
devins2518 committed Aug 23, 2021
1 parent 07c5152 commit 22c07af
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1908,11 +1908,12 @@ mod cmd {
let (_, doc) = current!(cx.editor);
let id = doc.id();

cx.editor.switch(id, Action::VerticalSplit);

let path = args.get(0).context("wrong argument count")?;
if let Some(path) = args.get(0) {
cx.editor.open(path.into(), Action::VerticalSplit)?;
} else {
cx.editor.switch(id, Action::VerticalSplit);
}

let _ = cx.editor.open(path.into(), Action::Replace)?;
Ok(())
}

Expand All @@ -1924,11 +1925,12 @@ mod cmd {
let (_, doc) = current!(cx.editor);
let id = doc.id();

cx.editor.switch(id, Action::HorizontalSplit);

let path = args.get(0).context("wrong argument count")?;
if let Some(path) = args.get(0) {
cx.editor.open(path.into(), Action::HorizontalSplit)?;
} else {
cx.editor.switch(id, Action::HorizontalSplit);
}

let _ = cx.editor.open(path.into(), Action::Replace)?;
Ok(())
}

Expand Down

0 comments on commit 22c07af

Please sign in to comment.