action/command: Align vsplit & hsplit to tab's multiopen handling

This commit is contained in:
Jöran Karl
2024-10-13 15:25:51 +02:00
parent 2c62d4b70c
commit acabf2b492
2 changed files with 20 additions and 15 deletions

View File

@@ -501,7 +501,7 @@ func (h *BufPane) HelpCmd(args []string) {
}
}
// VSplitCmd opens a vertical split with file given in the first argument
// VSplitCmd opens one or more vertical splits with the files given as arguments
// If no file is given, it opens an empty buffer in a new split
func (h *BufPane) VSplitCmd(args []string) {
if len(args) == 0 {
@@ -510,16 +510,18 @@ func (h *BufPane) VSplitCmd(args []string) {
return
}
buf, err := buffer.NewBufferFromFile(args[0], buffer.BTDefault)
if err != nil {
InfoBar.Error(err)
return
}
for _, a := range args {
buf, err := buffer.NewBufferFromFile(a, buffer.BTDefault)
if err != nil {
InfoBar.Error(err)
return
}
h.VSplitBuf(buf)
h.VSplitBuf(buf)
}
}
// HSplitCmd opens a horizontal split with file given in the first argument
// HSplitCmd opens one or more horizontal splits with the files given as arguments
// If no file is given, it opens an empty buffer in a new split
func (h *BufPane) HSplitCmd(args []string) {
if len(args) == 0 {
@@ -528,13 +530,15 @@ func (h *BufPane) HSplitCmd(args []string) {
return
}
buf, err := buffer.NewBufferFromFile(args[0], buffer.BTDefault)
if err != nil {
InfoBar.Error(err)
return
}
for _, a := range args {
buf, err := buffer.NewBufferFromFile(a, buffer.BTDefault)
if err != nil {
InfoBar.Error(err)
return
}
h.HSplitBuf(buf)
h.HSplitBuf(buf)
}
}
// EvalCmd evaluates a lua expression

View File

@@ -76,7 +76,8 @@ quotes here but these are not necessary when entering the command in micro.
command's output will be displayed in one line when it finishes running.
* `vsplit ['filename']`: opens a vertical split with `filename`. If no filename
is provided, a vertical split is opened with an empty buffer.
is provided, a vertical split is opened with an empty buffer. If multiple
files are provided (separated via ` `) they are opened all as splits.
* `hsplit ['filename']`: same as `vsplit` but opens a horizontal split instead
of a vertical split.