Skip to content

Commit

Permalink
Remove a few cases where Entry did two refreshes in a row
Browse files Browse the repository at this point in the history
Also includes a fix where SelectedText() allocated all of the new text once again.

For fyne-io#4397
  • Loading branch information
Jacalz committed Feb 27, 2024
1 parent 6b7246b commit 1ecc306
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions widget/entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ func (e *Entry) Redo() {
if !modify.Delete {
pos += len(modify.Text)
}
e.updateTextAndRefresh(newText, false)
e.propertyLock.Lock()
e.updateText(newText, false)
e.CursorRow, e.CursorColumn = e.rowColFromTextPos(pos)
e.propertyLock.Unlock()
e.Refresh()
Expand Down Expand Up @@ -510,7 +510,7 @@ func (e *Entry) SelectedText() string {
if start == stop {
return ""
}
r := ([]rune)(e.textProvider().String())
r := ([]rune)(e.Text)
return string(r[start:stop])
}

Expand Down Expand Up @@ -802,8 +802,8 @@ func (e *Entry) Undo() {
if modify.Delete {
pos += len(modify.Text)
}
e.updateTextAndRefresh(newText, false)
e.propertyLock.Lock()
e.updateText(newText, false)
e.CursorRow, e.CursorColumn = e.rowColFromTextPos(pos)
e.propertyLock.Unlock()
e.Refresh()
Expand Down Expand Up @@ -1065,10 +1065,10 @@ func (e *Entry) pasteFromClipboard(clipboard fyne.Clipboard) {
Position: pos,
Text: text,
})
e.updateText(provider.String(), false)
e.CursorRow, e.CursorColumn = e.rowColFromTextPos(pos + len(runes))
e.propertyLock.Unlock()

e.updateTextAndRefresh(provider.String(), false)
e.CursorRow, e.CursorColumn = e.rowColFromTextPos(pos + len(runes))
e.Refresh() // placing the cursor (and refreshing) happens last
}

Expand Down

0 comments on commit 1ecc306

Please sign in to comment.