Skip to content

Commit

Permalink
feat(textinput): expose matched suggestions and index
Browse files Browse the repository at this point in the history
  • Loading branch information
luevano authored and meowgorithm committed Sep 19, 2024
1 parent ed14316 commit 4382fdf
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions textinput/textinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,16 +813,29 @@ func (m Model) completionView(offset int) string {
return ""
}

// AvailableSuggestions returns the list of available suggestions.
func (m *Model) AvailableSuggestions() []string {
suggestions := make([]string, len(m.suggestions))
for i, s := range m.suggestions {
func (m *Model) getSuggestions(sugs [][]rune) []string {
suggestions := make([]string, len(sugs))
for i, s := range sugs {
suggestions[i] = string(s)
}

return suggestions
}

// AvailableSuggestions returns the list of available suggestions.
func (m *Model) AvailableSuggestions() []string {
return m.getSuggestions(m.suggestions)
}

// MatchedSuggestions returns the list of matched suggestions.
func (m *Model) MatchedSuggestions() []string {
return m.getSuggestions(m.matchedSuggestions)
}

// CurrentSuggestion returns the currently selected suggestion index.
func (m *Model) CurrentSuggestionIndex() int {
return m.currentSuggestionIndex
}

// CurrentSuggestion returns the currently selected suggestion.
func (m *Model) CurrentSuggestion() string {
if m.currentSuggestionIndex >= len(m.matchedSuggestions) {
Expand Down

0 comments on commit 4382fdf

Please sign in to comment.