1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2026-01-03 22:39:23 +03:00

do not close over variables in a function

This commit is contained in:
Jesse Duffield
2020-02-25 22:08:03 +11:00
parent e6a8dc0bcf
commit 8eb0b0f4ca

View File

@@ -16,10 +16,12 @@ func (gui *Gui) handleCreateRebaseOptionsMenu(g *gocui.Gui, v *gocui.View) error
menuItems := make([]*menuItem, len(options))
for i, option := range options {
// note to self. Never, EVER, close over loop variables in a function
innerOption := option
menuItems[i] = &menuItem{
displayString: option,
displayString: innerOption,
onPress: func() error {
return gui.genericMergeCommand(option)
return gui.genericMergeCommand(innerOption)
},
}
}