Add :vsplit and :hsplit commands (#639)
* add vsplit and hsplit commands * handle splits more elegantly
This commit is contained in:
parent
81984be9f4
commit
e1c9f13263
1 changed files with 48 additions and 0 deletions
|
@ -1900,6 +1900,40 @@ mod cmd {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn vsplit(
|
||||||
|
cx: &mut compositor::Context,
|
||||||
|
args: &[&str],
|
||||||
|
_event: PromptEvent,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
let (_, doc) = current!(cx.editor);
|
||||||
|
let id = doc.id();
|
||||||
|
|
||||||
|
if let Some(path) = args.get(0) {
|
||||||
|
cx.editor.open(path.into(), Action::VerticalSplit)?;
|
||||||
|
} else {
|
||||||
|
cx.editor.switch(id, Action::VerticalSplit);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn hsplit(
|
||||||
|
cx: &mut compositor::Context,
|
||||||
|
args: &[&str],
|
||||||
|
_event: PromptEvent,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
|
let (_, doc) = current!(cx.editor);
|
||||||
|
let id = doc.id();
|
||||||
|
|
||||||
|
if let Some(path) = args.get(0) {
|
||||||
|
cx.editor.open(path.into(), Action::HorizontalSplit)?;
|
||||||
|
} else {
|
||||||
|
cx.editor.switch(id, Action::HorizontalSplit);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
|
pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
|
||||||
TypableCommand {
|
TypableCommand {
|
||||||
name: "quit",
|
name: "quit",
|
||||||
|
@ -2138,6 +2172,20 @@ mod cmd {
|
||||||
doc: "Display tree sitter scopes, primarily for theming and development.",
|
doc: "Display tree sitter scopes, primarily for theming and development.",
|
||||||
fun: tree_sitter_scopes,
|
fun: tree_sitter_scopes,
|
||||||
completer: None,
|
completer: None,
|
||||||
|
},
|
||||||
|
TypableCommand {
|
||||||
|
name: "vsplit",
|
||||||
|
alias: Some("vsp"),
|
||||||
|
doc: "Open the file in a vertical split.",
|
||||||
|
fun: vsplit,
|
||||||
|
completer: Some(completers::filename),
|
||||||
|
},
|
||||||
|
TypableCommand {
|
||||||
|
name: "hsplit",
|
||||||
|
alias: Some("sp"),
|
||||||
|
doc: "Open the file in a horizontal split.",
|
||||||
|
fun: hsplit,
|
||||||
|
completer: Some(completers::filename),
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue