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

Fix and test case for 1737 #1766

Merged
merged 6 commits into from Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions widget/entry.go
Expand Up @@ -820,6 +820,9 @@ func (e *Entry) rowColFromTextPos(pos int) (row int, col int) {
row++
}
col = pos - b[0]
if e.Wrapping != fyne.TextWrapOff && b[0] == pos && col == 0 && pos != 0 {
stuartmscott marked this conversation as resolved.
Show resolved Hide resolved
row++
}
} else {
break
}
Expand Down
16 changes: 16 additions & 0 deletions widget/entry_test.go
Expand Up @@ -109,6 +109,22 @@ func TestEntry_CursorColumn_Wrap(t *testing.T) {
assert.Equal(t, 1, entry.CursorColumn)
}

func TestEntry_CursorColumn_Wrap2(t *testing.T) {
entry := widget.NewMultiLineEntry()
entry.Wrapping = fyne.TextWrapWord
entry.Resize(fyne.NewSize(64, 64))
entry.SetText("1234")
entry.CursorColumn = 3
test.Type(entry, "a")
test.Type(entry, "b")
test.Type(entry, "c")
assert.Equal(t, 1, entry.CursorColumn)
assert.Equal(t, 1, entry.CursorRow)
w := test.NewWindow(entry)
w.Resize(fyne.NewSize(70, 70))
test.AssertImageMatches(t, "entry/wrap_multi_line_cursor.png", w.Canvas().Capture())
}

func TestEntry_CursorPasswordRevealer(t *testing.T) {
pr := widget.NewPasswordEntry().ActionItem.(desktop.Cursorable)
assert.Equal(t, desktop.DefaultCursor, pr.Cursor())
Expand Down
Binary file added widget/testdata/entry/wrap_multi_line_cursor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.