mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-10-08 22:52:12 +02:00
Fix potential crash when reloading the config after removing a branch log command
When cycling to the last branch log command, and then editing the config to remove one or more log commands, lazygit would crash with an out of bounds panic when returning to it. Fix this by resetting the log index to 0 when it is out of bounds. (I think resetting to 0 is better than clamping, although it doesn't matter much.)
This commit is contained in:
@@ -278,6 +278,10 @@ func (self *BranchCommands) allBranchesLogCandidates() []string {
|
||||
func (self *BranchCommands) AllBranchesLogCmdObj() *oscommands.CmdObj {
|
||||
candidates := self.allBranchesLogCandidates()
|
||||
|
||||
if self.allBranchesLogCmdIndex >= len(candidates) {
|
||||
self.allBranchesLogCmdIndex = 0
|
||||
}
|
||||
|
||||
i := self.allBranchesLogCmdIndex
|
||||
return self.cmd.New(str.ToArgv(candidates[i])).DontLog()
|
||||
}
|
||||
|
Reference in New Issue
Block a user