@@ -428,7 +428,7 @@ func (h *BufPane) ReopenCmd(args []string) {
428428 }
429429}
430430
431- func (h * BufPane ) openHelp (page string ) error {
431+ func (h * BufPane ) openHelp (page string , hsplit bool , forceSplit bool ) error {
432432 if data , err := config .FindRuntimeFile (config .RTHelp , page ).Data (); err != nil {
433433 return errors .New (fmt .Sprintf ("Unable to load help text for %s: %v" , page , err ))
434434 } else {
@@ -437,10 +437,12 @@ func (h *BufPane) openHelp(page string) error {
437437 helpBuffer .SetOptionNative ("hltaberrors" , false )
438438 helpBuffer .SetOptionNative ("hltrailingws" , false )
439439
440- if h .Buf .Type == buffer .BTHelp {
440+ if h .Buf .Type == buffer .BTHelp && ! forceSplit {
441441 h .OpenBuffer (helpBuffer )
442- } else {
442+ } else if hsplit {
443443 h .HSplitBuf (helpBuffer )
444+ } else {
445+ h .VSplitBuf (helpBuffer )
444446 }
445447 }
446448 return nil
@@ -450,15 +452,49 @@ func (h *BufPane) openHelp(page string) error {
450452func (h * BufPane ) HelpCmd (args []string ) {
451453 if len (args ) < 1 {
452454 // Open the default help if the user just typed "> help"
453- h .openHelp ("help" )
455+ h .openHelp ("help" , true , false )
454456 } else {
455- if config .FindRuntimeFile (config .RTHelp , args [0 ]) != nil {
456- err := h .openHelp (args [0 ])
457+ var topics []string
458+ hsplit := true
459+ forceSplit := false
460+ const errSplit = "hsplit and vsplit are not allowed at the same time"
461+ for _ , arg := range args {
462+ switch arg {
463+ case "-vsplit" :
464+ if forceSplit {
465+ InfoBar .Error (errSplit )
466+ return
467+ }
468+ hsplit = false
469+ forceSplit = true
470+ case "-hsplit" :
471+ if forceSplit {
472+ InfoBar .Error (errSplit )
473+ return
474+ }
475+ hsplit = true
476+ forceSplit = true
477+ default :
478+ topics = append (topics , arg )
479+ }
480+ }
481+
482+ if len (topics ) < 1 {
483+ // Do the same as without arg
484+ h .openHelp ("help" , hsplit , forceSplit )
485+ return
486+ }
487+ if len (topics ) > 1 {
488+ forceSplit = true
489+ }
490+
491+ if config .FindRuntimeFile (config .RTHelp , topics [0 ]) != nil {
492+ err := h .openHelp (topics [0 ], hsplit , forceSplit )
457493 if err != nil {
458494 InfoBar .Error (err )
459495 }
460496 } else {
461- InfoBar .Error ("Sorry, no help for " , args [0 ])
497+ InfoBar .Error ("Sorry, no help for " , topics [0 ])
462498 }
463499 }
464500}
0 commit comments