mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	allow changing tabs with [ and ]
This commit is contained in:
		| @@ -372,3 +372,15 @@ func (gui *Gui) refreshRemotes() error { | ||||
|  | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (gui *Gui) handleNextBranchesTab(g *gocui.Gui, v *gocui.View) error { | ||||
| 	return gui.onBranchesTabClick( | ||||
| 		utils.ModuloWithWrap(v.TabIndex+1, len(v.Tabs)), | ||||
| 	) | ||||
| } | ||||
|  | ||||
| func (gui *Gui) handlePrevBranchesTab(g *gocui.Gui, v *gocui.View) error { | ||||
| 	return gui.onBranchesTabClick( | ||||
| 		utils.ModuloWithWrap(v.TabIndex-1, len(v.Tabs)), | ||||
| 	) | ||||
| } | ||||
|   | ||||
| @@ -402,6 +402,18 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { | ||||
| 			Handler:     gui.handleFastForward, | ||||
| 			Description: gui.Tr.SLocalize("FastForward"), | ||||
| 		}, | ||||
| 		{ | ||||
| 			ViewName: "branches", | ||||
| 			Key:      ']', | ||||
| 			Modifier: gocui.ModNone, | ||||
| 			Handler:  gui.handleNextBranchesTab, | ||||
| 		}, | ||||
| 		{ | ||||
| 			ViewName: "branches", | ||||
| 			Key:      '[', | ||||
| 			Modifier: gocui.ModNone, | ||||
| 			Handler:  gui.handlePrevBranchesTab, | ||||
| 		}, | ||||
| 		{ | ||||
| 			ViewName:    "commits", | ||||
| 			Key:         's', | ||||
|   | ||||
| @@ -299,3 +299,14 @@ func DifferenceInt(a, b []int) []int { | ||||
| 	} | ||||
| 	return result | ||||
| } | ||||
|  | ||||
| // used to keep a number n between 0 and max, allowing for wraparounds | ||||
| func ModuloWithWrap(n, max int) int { | ||||
| 	if n >= max { | ||||
| 		return n % max | ||||
| 	} else if n < 0 { | ||||
| 		return max + n | ||||
| 	} else { | ||||
| 		return n | ||||
| 	} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user