Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset all associated Entry variables when text is out of sync #1101

Merged
merged 2 commits into from Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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