From 5505bb7a5840259d25f7451c66fbfa65ba81a5eb Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Wed, 23 Sep 2020 15:44:28 -0700 Subject: [PATCH] Document changes submitted by Andreas Bieber --- CHANGELOG | 7 +++++++ demos/inputfield/autocomplete/main.go | 2 +- flex.go | 4 ++-- inputfield.go | 15 ++++++--------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index bc5aeaa..1389f67 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,12 @@ v1.5.0 (WIP) - Add scroll bar to TextView +- Add focus-driven style options +- Add InputField autocomplete style options +- Add arrow symbol to DropDown +- Add Makefile +- Revamp FormItem styling as FormItem.SetAttributes +- Provide DropDownOption in DropDown handlers +- Provide ListItem in List handlers v1.4.9 (2020-09-08) - Add InputField.GetCursorPosition and InputField.SetCursorPosition diff --git a/demos/inputfield/autocomplete/main.go b/demos/inputfield/autocomplete/main.go index 72809f1..caa7019 100644 --- a/demos/inputfield/autocomplete/main.go +++ b/demos/inputfield/autocomplete/main.go @@ -28,7 +28,7 @@ func main() { entries = append(entries, cview.NewListItem(word)) } } - if len(entries) <= 1 { + if len(entries) == 0 { entries = nil } return diff --git a/flex.go b/flex.go index d6fd01b..a7bd9fb 100644 --- a/flex.go +++ b/flex.go @@ -61,8 +61,8 @@ func NewFlex() *Flex { // GetDirection returns the direction in which the contained primitives are // distributed. This can be either FlexColumn (default) or FlexRow. func (f *Flex) GetDirection() int { - f.l.RLock() - defer f.l.RUnlock() + f.RLock() + defer f.RUnlock() return f.direction } diff --git a/inputfield.go b/inputfield.go index 9c72529..45f398e 100644 --- a/inputfield.go +++ b/inputfield.go @@ -510,11 +510,12 @@ 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 referenceVal, isString := item.reference.(string); isString { - i.autocompleteListSuggestion = referenceVal[len(i.text):] - } else { - i.autocompleteListSuggestion = item.mainText[len(i.text):] + if len(i.text) >= len(item.mainText) { + i.autocompleteListSuggestion = "" + return } + + i.autocompleteListSuggestion = item.mainText[len(i.text):] } // SetAcceptanceFunc sets a handler which may reject the last character that was @@ -857,11 +858,7 @@ func (i *InputField) InputHandler() func(event *tcell.EventKey, setFocus func(p if i.autocompleteList != nil { currentItem := i.autocompleteList.GetCurrentItem() i.Unlock() - if referenceVal, isString := currentItem.reference.(string); isString { - i.SetText(referenceVal) - } else { - i.SetText(currentItem.mainText) - } + i.SetText(currentItem.mainText) i.Lock() i.autocompleteList = nil i.autocompleteListSuggestion = ""