Add horizontal and vertical split scratch buffers (#1763)

Make subcommand name more descriptive

Fix vsplit completer

Run cargo xtask docgen
pull/1811/head^2
Joe 3 years ago committed by GitHub
parent 85492e587c
commit c0dbd6dc3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -46,7 +46,9 @@
| `:debug-remote`, `:dbg-tcp` | Connect to a debug adapter by TCP address and start a debugging session from a given template with given parameters. | | `:debug-remote`, `:dbg-tcp` | Connect to a debug adapter by TCP address and start a debugging session from a given template with given parameters. |
| `:debug-eval` | Evaluate expression in current debug context. | | `:debug-eval` | Evaluate expression in current debug context. |
| `:vsplit`, `:vs` | Open the file in a vertical split. | | `:vsplit`, `:vs` | Open the file in a vertical split. |
| `:vsplit-new`, `:vnew` | Open a scratch buffer in a vertical split. |
| `:hsplit`, `:hs`, `:sp` | Open the file in a horizontal split. | | `:hsplit`, `:hs`, `:sp` | Open the file in a horizontal split. |
| `:hsplit-new`, `:hnew` | Open a scratch buffer in a horizontal split. |
| `:tutor` | Open the tutorial. | | `:tutor` | Open the tutorial. |
| `:goto`, `:g` | Go to line number. | | `:goto`, `:g` | Go to line number. |
| `:set-option`, `:set` | Set a config option at runtime | | `:set-option`, `:set` | Set a config option at runtime |

@ -380,7 +380,9 @@ impl MappableCommand {
jump_view_down, "Jump to the split below", jump_view_down, "Jump to the split below",
rotate_view, "Goto next window", rotate_view, "Goto next window",
hsplit, "Horizontal bottom split", hsplit, "Horizontal bottom split",
hsplit_new, "Horizontal bottom split scratch buffer",
vsplit, "Vertical right split", vsplit, "Vertical right split",
vsplit_new, "Vertical right split scratch buffer",
wclose, "Close window", wclose, "Close window",
wonly, "Current window only", wonly, "Current window only",
select_register, "Select register", select_register, "Select register",
@ -3794,10 +3796,18 @@ fn hsplit(cx: &mut Context) {
split(cx, Action::HorizontalSplit); split(cx, Action::HorizontalSplit);
} }
fn hsplit_new(cx: &mut Context) {
cx.editor.new_file(Action::HorizontalSplit);
}
fn vsplit(cx: &mut Context) { fn vsplit(cx: &mut Context) {
split(cx, Action::VerticalSplit); split(cx, Action::VerticalSplit);
} }
fn vsplit_new(cx: &mut Context) {
cx.editor.new_file(Action::VerticalSplit);
}
fn wclose(cx: &mut Context) { fn wclose(cx: &mut Context) {
if cx.editor.tree.views().count() == 1 { if cx.editor.tree.views().count() == 1 {
if let Err(err) = typed::buffers_remaining_impl(cx.editor) { if let Err(err) = typed::buffers_remaining_impl(cx.editor) {

@ -771,6 +771,26 @@ fn hsplit(
Ok(()) Ok(())
} }
fn vsplit_new(
cx: &mut compositor::Context,
_args: &[Cow<str>],
_event: PromptEvent,
) -> anyhow::Result<()> {
cx.editor.new_file(Action::VerticalSplit);
Ok(())
}
fn hsplit_new(
cx: &mut compositor::Context,
_args: &[Cow<str>],
_event: PromptEvent,
) -> anyhow::Result<()> {
cx.editor.new_file(Action::HorizontalSplit);
Ok(())
}
fn debug_eval( fn debug_eval(
cx: &mut compositor::Context, cx: &mut compositor::Context,
args: &[Cow<str>], args: &[Cow<str>],
@ -1293,6 +1313,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
fun: vsplit, fun: vsplit,
completer: Some(completers::filename), completer: Some(completers::filename),
}, },
TypableCommand {
name: "vsplit-new",
aliases: &["vnew"],
doc: "Open a scratch buffer in a vertical split.",
fun: vsplit_new,
completer: None,
},
TypableCommand { TypableCommand {
name: "hsplit", name: "hsplit",
aliases: &["hs", "sp"], aliases: &["hs", "sp"],
@ -1300,6 +1327,13 @@ pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
fun: hsplit, fun: hsplit,
completer: Some(completers::filename), completer: Some(completers::filename),
}, },
TypableCommand {
name: "hsplit-new",
aliases: &["hnew"],
doc: "Open a scratch buffer in a horizontal split.",
fun: hsplit_new,
completer: None,
},
TypableCommand { TypableCommand {
name: "tutor", name: "tutor",
aliases: &[], aliases: &[],

@ -682,6 +682,10 @@ impl Default for Keymaps {
"C-j" | "j" | "down" => jump_view_down, "C-j" | "j" | "down" => jump_view_down,
"C-k" | "k" | "up" => jump_view_up, "C-k" | "k" | "up" => jump_view_up,
"C-l" | "l" | "right" => jump_view_right, "C-l" | "l" | "right" => jump_view_right,
"n" => { "New split scratch buffer"
"C-s" | "s" => hsplit_new,
"C-v" | "v" => vsplit_new,
},
}, },
// move under <space>c // move under <space>c
@ -732,6 +736,10 @@ impl Default for Keymaps {
"C-j" | "j" | "down" => jump_view_down, "C-j" | "j" | "down" => jump_view_down,
"C-k" | "k" | "up" => jump_view_up, "C-k" | "k" | "up" => jump_view_up,
"C-l" | "l" | "right" => jump_view_right, "C-l" | "l" | "right" => jump_view_right,
"n" => { "New split scratch buffer"
"C-s" | "s" => hsplit_new,
"C-v" | "v" => vsplit_new,
},
}, },
"y" => yank_joined_to_clipboard, "y" => yank_joined_to_clipboard,
"Y" => yank_main_selection_to_clipboard, "Y" => yank_main_selection_to_clipboard,

Loading…
Cancel
Save