@@ -1793,27 +1793,38 @@ func (h *BufPane) AddTab() bool {
17931793
17941794// PreviousTab switches to the previous tab in the tab list
17951795func (h * BufPane ) PreviousTab () bool {
1796- tabsLen := len (Tabs .List )
1797- if tabsLen == 1 {
1796+ if Tabs .Active () == 0 {
17981797 return false
17991798 }
1800-
1801- a := Tabs .Active () + tabsLen
1802- Tabs .SetActive ((a - 1 ) % tabsLen )
1803-
1799+ Tabs .SetActive (Tabs .Active () - 1 )
18041800 return true
18051801}
18061802
18071803// NextTab switches to the next tab in the tab list
18081804func (h * BufPane ) NextTab () bool {
1809- tabsLen := len (Tabs .List )
1810- if tabsLen == 1 {
1805+ if Tabs .Active () == len (Tabs .List )- 1 {
18111806 return false
18121807 }
1808+ Tabs .SetActive (Tabs .Active () + 1 )
1809+ return true
1810+ }
18131811
1814- a := Tabs .Active ()
1815- Tabs .SetActive ((a + 1 ) % tabsLen )
1812+ // FirstTab switches to the first tab in the tab list
1813+ func (h * BufPane ) FirstTab () bool {
1814+ if Tabs .Active () == 0 {
1815+ return false
1816+ }
1817+ Tabs .SetActive (0 )
1818+ return true
1819+ }
18161820
1821+ // LastTab switches to the last tab in the tab list
1822+ func (h * BufPane ) LastTab () bool {
1823+ lastTabIndex := len (Tabs .List ) - 1
1824+ if Tabs .Active () == lastTabIndex {
1825+ return false
1826+ }
1827+ Tabs .SetActive (lastTabIndex )
18171828 return true
18181829}
18191830
@@ -1848,36 +1859,38 @@ func (h *BufPane) Unsplit() bool {
18481859
18491860// NextSplit changes the view to the next split
18501861func (h * BufPane ) NextSplit () bool {
1851- if len ( h .tab .Panes ) == 1 {
1862+ if h .tab .active == len ( h . tab . Panes ) - 1 {
18521863 return false
18531864 }
1854-
1855- a := h .tab .active
1856- if a < len (h .tab .Panes )- 1 {
1857- a ++
1858- } else {
1859- a = 0
1860- }
1861-
1862- h .tab .SetActive (a )
1863-
1865+ h .tab .SetActive (h .tab .active + 1 )
18641866 return true
18651867}
18661868
18671869// PreviousSplit changes the view to the previous split
18681870func (h * BufPane ) PreviousSplit () bool {
1869- if len ( h .tab .Panes ) == 1 {
1871+ if h .tab .active == 0 {
18701872 return false
18711873 }
1874+ h .tab .SetActive (h .tab .active - 1 )
1875+ return true
1876+ }
18721877
1873- a := h .tab .active
1874- if a > 0 {
1875- a --
1876- } else {
1877- a = len (h .tab .Panes ) - 1
1878+ // FirstSplit changes the view to the first split
1879+ func (h * BufPane ) FirstSplit () bool {
1880+ if h .tab .active == 0 {
1881+ return false
18781882 }
1879- h .tab .SetActive (a )
1883+ h .tab .SetActive (0 )
1884+ return true
1885+ }
18801886
1887+ // LastSplit changes the view to the last split
1888+ func (h * BufPane ) LastSplit () bool {
1889+ lastPaneIdx := len (h .tab .Panes ) - 1
1890+ if h .tab .active == lastPaneIdx {
1891+ return false
1892+ }
1893+ h .tab .SetActive (lastPaneIdx )
18811894 return true
18821895}
18831896
0 commit comments