MCPcopy Index your code
hub / github.com/git-bug/git-bug / addItem

Method addItem

termui/label_select.go:232–267  ·  view source on GitHub ↗
(g *gocui.Gui, v *gocui.View)

Source from the content-addressed store, hash-verified

230}
231
232func (ls *labelSelect) addItem(g *gocui.Gui, v *gocui.View) error {
233 c := ui.inputPopup.Activate("Add a new label")
234
235 go func() {
236 input := <-c
237
238 // Standardize label format
239 input = strings.TrimSuffix(input, "\n")
240 input = strings.Replace(input, " ", "-", -1)
241
242 // Check if label already exists
243 for i, label := range ls.labels {
244 if input == label.String() {
245 ls.labelSelect[i] = true
246 ls.selected = i
247
248 g.Update(func(gui *gocui.Gui) error {
249 return ls.focusView(g)
250 })
251
252 return
253 }
254 }
255
256 // Add new label, make it selected, and focus
257 ls.labels = append(ls.labels, common.Label(input))
258 ls.labelSelect = append(ls.labelSelect, true)
259 ls.selected = len(ls.labels) - 1
260
261 g.Update(func(g *gocui.Gui) error {
262 return nil
263 })
264 }()
265
266 return nil
267}
268
269func (ls *labelSelect) abort(g *gocui.Gui, v *gocui.View) error {
270 return ui.activateWindow(ui.showBug)

Callers

nothing calls this directly

Calls 4

focusViewMethod · 0.95
LabelTypeAlias · 0.92
StringMethod · 0.65
ActivateMethod · 0.45

Tested by

no test coverage detected