2020-11-28 04:14:48 +02:00
|
|
|
package gui
|
|
|
|
|
2020-11-28 11:01:45 +02:00
|
|
|
import (
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
|
|
|
)
|
2020-11-28 10:53:39 +02:00
|
|
|
|
|
|
|
func (gui *Gui) getSelectedSuggestionValue() string {
|
|
|
|
selectedSuggestion := gui.getSelectedSuggestion()
|
|
|
|
|
|
|
|
if selectedSuggestion != nil {
|
|
|
|
return selectedSuggestion.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func (gui *Gui) getSelectedSuggestion() *types.Suggestion {
|
2020-11-28 04:14:48 +02:00
|
|
|
selectedLine := gui.State.Panels.Suggestions.SelectedLineIdx
|
|
|
|
if selectedLine == -1 {
|
2020-11-28 10:53:39 +02:00
|
|
|
return nil
|
2020-11-28 04:14:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return gui.State.Suggestions[selectedLine]
|
|
|
|
}
|
|
|
|
|
2020-11-28 10:53:39 +02:00
|
|
|
func (gui *Gui) setSuggestions(suggestions []*types.Suggestion) {
|
2020-11-28 04:14:48 +02:00
|
|
|
view := gui.getSuggestionsView()
|
|
|
|
if view == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
gui.State.Suggestions = suggestions
|
|
|
|
gui.State.Panels.Suggestions.SelectedLineIdx = 0
|
|
|
|
_ = gui.resetOrigin(view)
|
2021-04-03 02:32:14 +02:00
|
|
|
_ = gui.Contexts.Suggestions.HandleRender()
|
2020-11-28 04:14:48 +02:00
|
|
|
}
|