(idx int)
| 454 | } |
| 455 | |
| 456 | func (v *PricingView) toggleSuggestion(idx int) { |
| 457 | if idx >= len(v.SuggestionsCache) { |
| 458 | return |
| 459 | } |
| 460 | value := v.SuggestionsCache[idx].Value |
| 461 | if value == "" { |
| 462 | return |
| 463 | } |
| 464 | |
| 465 | // Attrs phase 1: key name without '=' → transition to value selection |
| 466 | if v.CommandBuilder.SelectedField == 2 && !strings.Contains(value, "=") { |
| 467 | v.CommandBuilder.SearchInput = value + "=" |
| 468 | v.UpdateSuggestions() |
| 469 | return |
| 470 | } |
| 471 | // Price field: set input directly |
| 472 | if v.CommandBuilder.SelectedField == 3 { |
| 473 | v.CommandBuilder.SearchInput = value |
| 474 | v.UpdateSuggestions() |
| 475 | v.SuggestionIndex = -1 |
| 476 | return |
| 477 | } |
| 478 | |
| 479 | tags := v.CommandBuilder.CurrentTags() |
| 480 | found := -1 |
| 481 | for i, t := range tags { |
| 482 | if t == value { |
| 483 | found = i |
| 484 | break |
| 485 | } |
| 486 | } |
| 487 | if found >= 0 { |
| 488 | tags = append(tags[:found], tags[found+1:]...) |
| 489 | } else { |
| 490 | tags = append(tags, value) |
| 491 | } |
| 492 | v.CommandBuilder.SetCurrentTags(tags) |
| 493 | v.CommandBuilder.SearchInput = "" |
| 494 | v.UpdateSuggestions() |
| 495 | // Keep cursor on same item |
| 496 | for i, s := range v.SuggestionsCache { |
| 497 | if s.Value == value { |
| 498 | v.SuggestionIndex = i |
| 499 | return |
| 500 | } |
| 501 | } |
| 502 | if v.SuggestionIndex >= len(v.SuggestionsCache) && len(v.SuggestionsCache) > 0 { |
| 503 | v.SuggestionIndex = len(v.SuggestionsCache) - 1 |
| 504 | } |
| 505 | v.FilterItems() |
| 506 | } |
| 507 | |
| 508 | // UpdateSuggestions rebuilds the suggestion cache. |
| 509 | func (v *PricingView) UpdateSuggestions() { |
no test coverage detected