Browse Source

Merge branch 'fix/inputfield-suggestion' into 'master'

fix(inputfield): Display suggestion correctly

Closes #37

See merge request tslocum/cview!6
tablepad
Trevor Slocum 2 years ago
parent
commit
f83115be61
  1. 9
      inputfield.go

9
inputfield.go

@ -501,12 +501,13 @@ func (i *InputField) Autocomplete() *InputField {
// autocompleteChanged gets called when another item in the
// autocomplete list has been selected.
func (i *InputField) autocompleteChanged(_ int, item *ListItem) {
if len(i.text) >= len(item.mainText) {
if len(item.secondaryText) > 0 && len(i.text) < len(item.secondaryText) {
i.autocompleteListSuggestion = item.secondaryText[len(i.text):]
} else if len(item.mainText) > len(i.text)+1 {
i.autocompleteListSuggestion = item.mainText[len(i.text)+1:]
} else {
i.autocompleteListSuggestion = ""
return
}
i.autocompleteListSuggestion = item.mainText[len(i.text):]
}
// SetAcceptanceFunc sets a handler which may reject the last character that was

Loading…
Cancel
Save