Skip to content

Commit acabf2b

Browse files
committed
action/command: Align vsplit & hsplit to tab's multiopen handling
1 parent 2c62d4b commit acabf2b

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

internal/action/command.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ func (h *BufPane) HelpCmd(args []string) {
501501
}
502502
}
503503

504-
// VSplitCmd opens a vertical split with file given in the first argument
504+
// VSplitCmd opens one or more vertical splits with the files given as arguments
505505
// If no file is given, it opens an empty buffer in a new split
506506
func (h *BufPane) VSplitCmd(args []string) {
507507
if len(args) == 0 {
@@ -510,16 +510,18 @@ func (h *BufPane) VSplitCmd(args []string) {
510510
return
511511
}
512512

513-
buf, err := buffer.NewBufferFromFile(args[0], buffer.BTDefault)
514-
if err != nil {
515-
InfoBar.Error(err)
516-
return
517-
}
513+
for _, a := range args {
514+
buf, err := buffer.NewBufferFromFile(a, buffer.BTDefault)
515+
if err != nil {
516+
InfoBar.Error(err)
517+
return
518+
}
518519

519-
h.VSplitBuf(buf)
520+
h.VSplitBuf(buf)
521+
}
520522
}
521523

522-
// HSplitCmd opens a horizontal split with file given in the first argument
524+
// HSplitCmd opens one or more horizontal splits with the files given as arguments
523525
// If no file is given, it opens an empty buffer in a new split
524526
func (h *BufPane) HSplitCmd(args []string) {
525527
if len(args) == 0 {
@@ -528,13 +530,15 @@ func (h *BufPane) HSplitCmd(args []string) {
528530
return
529531
}
530532

531-
buf, err := buffer.NewBufferFromFile(args[0], buffer.BTDefault)
532-
if err != nil {
533-
InfoBar.Error(err)
534-
return
535-
}
533+
for _, a := range args {
534+
buf, err := buffer.NewBufferFromFile(a, buffer.BTDefault)
535+
if err != nil {
536+
InfoBar.Error(err)
537+
return
538+
}
536539

537-
h.HSplitBuf(buf)
540+
h.HSplitBuf(buf)
541+
}
538542
}
539543

540544
// EvalCmd evaluates a lua expression

runtime/help/commands.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ quotes here but these are not necessary when entering the command in micro.
7676
command's output will be displayed in one line when it finishes running.
7777

7878
* `vsplit ['filename']`: opens a vertical split with `filename`. If no filename
79-
is provided, a vertical split is opened with an empty buffer.
79+
is provided, a vertical split is opened with an empty buffer. If multiple
80+
files are provided (separated via ` `) they are opened all as splits.
8081

8182
* `hsplit ['filename']`: same as `vsplit` but opens a horizontal split instead
8283
of a vertical split.

0 commit comments

Comments
 (0)