Skip to content

Commit

Permalink
Also move selection start so selected markers move
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Nov 27, 2022
1 parent 33badb0 commit a0a7d19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions widget/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,7 @@ func (r *entryRenderer) Layout(size fyne.Size) {

r.entry.propertyLock.Lock()
textPos := r.entry.textPosFromRowCol(r.entry.CursorRow, r.entry.CursorColumn)
selectPos := r.entry.textPosFromRowCol(r.entry.selectRow, r.entry.selectColumn)
r.entry.propertyLock.Unlock()
if r.entry.Wrapping == fyne.TextWrapOff {
r.entry.content.Resize(entrySize)
Expand All @@ -1320,6 +1321,10 @@ func (r *entryRenderer) Layout(size fyne.Size) {
if textPos != resizedTextPos {
r.entry.setFieldsAndRefresh(func() {
r.entry.CursorRow, r.entry.CursorColumn = r.entry.rowColFromTextPos(textPos)

if r.entry.selecting {
r.entry.selectRow, r.entry.selectColumn = r.entry.rowColFromTextPos(selectPos)
}
})
}
}
Expand Down
6 changes: 6 additions & 0 deletions widget/entry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ func TestEntry_CursorColumn_Wrap2(t *testing.T) {
w.Resize(fyne.NewSize(70, 70))
assert.Equal(t, 1, entry.CursorColumn)
test.AssertImageMatches(t, "entry/wrap_multi_line_cursor.png", w.Canvas().Capture())

typeKeys(entry, keyShiftLeftDown, fyne.KeyLeft, keyShiftLeftUp)
assert.Equal(t, "c", entry.SelectedText())
assert.Equal(t, 0, entry.CursorColumn)
w.Resize(fyne.NewSize(64, 78))
assert.Equal(t, "c", entry.SelectedText())
}

func TestEntry_CursorPasswordRevealer(t *testing.T) {
Expand Down

0 comments on commit a0a7d19

Please sign in to comment.