@@ -1871,27 +1871,38 @@ func (h *BufPane) AddTab() bool {
18711871
18721872// PreviousTab switches to the previous tab in the tab list
18731873func (h * BufPane ) PreviousTab () bool {
1874- tabsLen := len (Tabs .List )
1875- if tabsLen == 1 {
1874+ if Tabs .Active () == 0 {
18761875 return false
18771876 }
1878-
1879- a := Tabs .Active () + tabsLen
1880- Tabs .SetActive ((a - 1 ) % tabsLen )
1881-
1877+ Tabs .SetActive (Tabs .Active () - 1 )
18821878 return true
18831879}
18841880
18851881// NextTab switches to the next tab in the tab list
18861882func (h * BufPane ) NextTab () bool {
1887- tabsLen := len (Tabs .List )
1888- if tabsLen == 1 {
1883+ if Tabs .Active () == len (Tabs .List )- 1 {
18891884 return false
18901885 }
1886+ Tabs .SetActive (Tabs .Active () + 1 )
1887+ return true
1888+ }
18911889
1892- a := Tabs .Active ()
1893- Tabs .SetActive ((a + 1 ) % tabsLen )
1890+ // FirstTab switches to the first tab in the tab list
1891+ func (h * BufPane ) FirstTab () bool {
1892+ if Tabs .Active () == 0 {
1893+ return false
1894+ }
1895+ Tabs .SetActive (0 )
1896+ return true
1897+ }
18941898
1899+ // LastTab switches to the last tab in the tab list
1900+ func (h * BufPane ) LastTab () bool {
1901+ lastTabIndex := len (Tabs .List ) - 1
1902+ if Tabs .Active () == lastTabIndex {
1903+ return false
1904+ }
1905+ Tabs .SetActive (lastTabIndex )
18951906 return true
18961907}
18971908
@@ -1926,36 +1937,38 @@ func (h *BufPane) Unsplit() bool {
19261937
19271938// NextSplit changes the view to the next split
19281939func (h * BufPane ) NextSplit () bool {
1929- if len ( h .tab .Panes ) == 1 {
1940+ if h .tab .active == len ( h . tab . Panes ) - 1 {
19301941 return false
19311942 }
1932-
1933- a := h .tab .active
1934- if a < len (h .tab .Panes )- 1 {
1935- a ++
1936- } else {
1937- a = 0
1938- }
1939-
1940- h .tab .SetActive (a )
1941-
1943+ h .tab .SetActive (h .tab .active + 1 )
19421944 return true
19431945}
19441946
19451947// PreviousSplit changes the view to the previous split
19461948func (h * BufPane ) PreviousSplit () bool {
1947- if len ( h .tab .Panes ) == 1 {
1949+ if h .tab .active == 0 {
19481950 return false
19491951 }
1952+ h .tab .SetActive (h .tab .active - 1 )
1953+ return true
1954+ }
19501955
1951- a := h .tab .active
1952- if a > 0 {
1953- a --
1954- } else {
1955- a = len (h .tab .Panes ) - 1
1956+ // FirstSplit changes the view to the first split
1957+ func (h * BufPane ) FirstSplit () bool {
1958+ if h .tab .active == 0 {
1959+ return false
19561960 }
1957- h .tab .SetActive (a )
1961+ h .tab .SetActive (0 )
1962+ return true
1963+ }
19581964
1965+ // LastSplit changes the view to the last split
1966+ func (h * BufPane ) LastSplit () bool {
1967+ lastPaneIdx := len (h .tab .Panes ) - 1
1968+ if h .tab .active == lastPaneIdx {
1969+ return false
1970+ }
1971+ h .tab .SetActive (lastPaneIdx )
19591972 return true
19601973}
19611974
0 commit comments