1212import warnings
1313from typing import overload
1414
15+ from _pytest import cacheprovider
16+
1517from libtmux .common import has_gte_version , has_lt_version , tmux_cmd
1618from libtmux .constants import (
1719 RESIZE_ADJUSTMENT_DIRECTION_FLAG_MAP ,
20+ SPLIT_WINDOW_DIRECTION_FLAG_MAP ,
1821 ResizeAdjustmentDirection ,
22+ SplitWindowDirection ,
1923)
2024from libtmux .formats import FORMAT_SEPARATOR
2125from libtmux .neo import Obj , fetch_obj
@@ -489,15 +493,14 @@ def split(
489493 self ,
490494 start_directory : t .Optional [str ] = None ,
491495 attach : bool = False ,
492- vertical : bool = True ,
496+ direction : t . Optional [ SplitWindowDirection ] = None ,
493497 shell : t .Optional [str ] = None ,
494498 size : t .Optional [t .Union [str , int ]] = None ,
495- percent : t .Optional [int ] = None , # deprecated
496499 environment : t .Optional [t .Dict [str , str ]] = None ,
500+ percent : t .Optional [int ] = None , # deprecated
501+ vertical : t .Optional [bool ] = None ,
497502 ) -> "Pane" :
498- """Split window and return the created :class:`Pane`.
499-
500- Used for splitting window and holding in a python object.
503+ """Split window and return :class:`Pane`, by default beneath current pane.
501504
502505 Parameters
503506 ----------
@@ -506,8 +509,8 @@ def split(
506509 True.
507510 start_directory : str, optional
508511 specifies the working directory in which the new window is created.
509- vertical : bool , optional
510- split vertically
512+ direction : SplitWindowDirection , optional
513+ split in direction. If none is specified, assume down.
511514 shell : str, optional
512515 execute a command on splitting the window. The pane will close
513516 when the command exits.
@@ -522,6 +525,8 @@ def split(
522525 window.
523526 environment: dict, optional
524527 Environmental variables for new pane. tmux 3.0+ only. Passthrough to ``-e``.
528+ vertical : bool, optional
529+ split vertically, deprecated by ``direction``.
525530
526531 Notes
527532 -----
@@ -534,6 +539,11 @@ def split(
534539 active. To remain on the same window and split the pane in another
535540 target window, pass in ``attach=False``.
536541
542+ .. deprecated:: 0.33.0
543+
544+ ``vertical=True`` deprecated in favor of
545+ ``direction=SplitWindowDirection.Below``.
546+
537547 .. versionchanged:: 0.28.0
538548
539549 ``attach`` default changed from ``True`` to ``False``.
@@ -546,10 +556,28 @@ def split(
546556
547557 tmux_args : t .Tuple [str , ...] = ()
548558
549- if vertical :
550- tmux_args += ("-v" ,)
559+ if direction :
560+ tmux_args += tuple (SPLIT_WINDOW_DIRECTION_FLAG_MAP [direction ])
561+ if vertical is not None :
562+ warnings .warn (
563+ "vertical is not required to pass with direction." ,
564+ category = DeprecationWarning ,
565+ stacklevel = 2 ,
566+ )
567+ elif vertical is not None :
568+ warnings .warn (
569+ "vertical is deprecated in favor of direction." ,
570+ category = DeprecationWarning ,
571+ stacklevel = 2 ,
572+ )
573+ if vertical :
574+ tmux_args += ("-v" ,)
575+ else :
576+ tmux_args += ("-h" ,)
551577 else :
552- tmux_args += ("-h" ,)
578+ tmux_args += tuple (
579+ SPLIT_WINDOW_DIRECTION_FLAG_MAP [SplitWindowDirection .Below ]
580+ )
553581
554582 if size is not None :
555583 if has_lt_version ("3.1" ):
0 commit comments