Skip to content

Commit

Permalink
Reset all associated Entry variables when text is out of sync
Browse files Browse the repository at this point in the history
Fixes #1096
  • Loading branch information
andydotxyz committed Jun 16, 2020
1 parent 60ff88c commit 7b8db4d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion widget/entry.go
Expand Up @@ -1034,7 +1034,7 @@ func (r *entryRenderer) Refresh() {
r.entry.propertyLock.RUnlock()

if content != string(provider.buffer) {
provider.setText(content)
r.entry.SetText(content)
return
}

Expand Down
16 changes: 16 additions & 0 deletions widget/entry_test.go
Expand Up @@ -134,6 +134,22 @@ func TestEntry_SetText_Manual(t *testing.T) {
test.AssertImageMatches(t, "entry/set_text_changed.png", c.Capture())
}

func TestEntry_SetText_Underflow(t *testing.T) {
entry := widget.NewEntry()
test.Type(entry, "test")
assert.Equal(t, 4, entry.CursorColumn)

entry.Text = ""
entry.Refresh()
assert.Equal(t, 0, entry.CursorColumn)

key := &fyne.KeyEvent{Name: fyne.KeyBackspace}
entry.TypedKey(key)

assert.Equal(t, 0, entry.CursorColumn)
assert.Equal(t, "", entry.Text)
}

func TestEntry_OnKeyDown(t *testing.T) {
entry := widget.NewEntry()

Expand Down

0 comments on commit 7b8db4d

Please sign in to comment.