Skip to content

Commit 194612a

Browse files
committed
hotfix: recover from wrong editingState
1 parent e75d3ab commit 194612a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

textinput.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,18 @@ func (p *textinputPlugin) handleSetEditingState(arguments interface{}) (reply in
9393
return nil, errors.Wrap(err, "failed to decode json arguments for handleSetEditingState")
9494
}
9595

96-
p.word = []rune(editingState.Text)
97-
9896
if editingState.SelectionBase < 0 || editingState.SelectionExtent < 0 {
99-
errorMsg := fmt.Sprintf("text editing state BUG, text selection isn't possible: selectionBase:%v, selectionExtent:%v. Please open a issue on flutter/flutter\n",
97+
errorMsg := fmt.Sprintf("text selection values aren't possible: selectionBase:%v, selectionExtent:%v. Refer to flutter/flutter#20016\n",
10098
editingState.SelectionBase, editingState.SelectionExtent)
101-
p.selectionBase = 0
102-
p.selectionExtent = 0
103-
return nil, errors.New(errorMsg)
99+
wordLen := len(p.word)
100+
p.selectionBase = wordLen
101+
p.selectionExtent = wordLen
102+
p.updateEditingState()
103+
fmt.Printf("go-flutter: recover from wrong editingState: %s", errorMsg)
104+
return nil, nil
104105
}
105106

107+
p.word = []rune(editingState.Text)
106108
p.selectionBase = editingState.SelectionBase
107109
p.selectionExtent = editingState.SelectionExtent
108110
return nil, nil

0 commit comments

Comments
 (0)