From 1ecc306624a7461a973836b3ca9a655fe2ac7a91 Mon Sep 17 00:00:00 2001 From: Jacob Date: Tue, 27 Feb 2024 09:03:37 +0100 Subject: [PATCH] Remove a few cases where Entry did two refreshes in a row Also includes a fix where SelectedText() allocated all of the new text once again. For #4397 --- widget/entry.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/widget/entry.go b/widget/entry.go index 1398341d2c..f5e1f0ad85 100644 --- a/widget/entry.go +++ b/widget/entry.go @@ -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() @@ -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]) } @@ -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() @@ -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 }