Skip to content

Commit

Permalink
do not close over variables in a function
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseduffield committed Feb 25, 2020
1 parent e6a8dc0 commit 8eb0b0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/gui/rebase_options_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
}
}
Expand Down

0 comments on commit 8eb0b0f

Please sign in to comment.