Unverified Commit 08768e87 authored by Dan Field's avatar Dan Field Committed by GitHub

Revert repeater (#52752)

Reverts repeat filter logic for text formatter
parent d1b99f43
......@@ -1230,9 +1230,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
// _lastFormattedUnmodifiedTextEditingValue tracks the last value
// that the formatter ran on and is used to prevent double-formatting.
TextEditingValue _lastFormattedUnmodifiedTextEditingValue;
// _lastFormattedValue tracks the last post-format value, so that it can be
// reused without rerunning the formatter when the input value is repeated.
TextEditingValue _lastFormattedValue;
// _receivedRemoteTextEditingValue is the direct value last passed in
// updateEditingValue. This value does not get updated with the formatted
// version.
......@@ -1663,29 +1660,15 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
// Check if the new value is the same as the current local value, or is the same
// as the post-formatting value of the previous pass.
final bool textChanged = _value?.text != value?.text;
final bool isRepeatText = value?.text == _lastFormattedUnmodifiedTextEditingValue?.text;
final bool isRepeatSelection = value?.selection == _lastFormattedUnmodifiedTextEditingValue?.selection;
// Only format when the text has changed and there are available formatters.
if (!isRepeatText && textChanged && widget.inputFormatters != null && widget.inputFormatters.isNotEmpty) {
for (final TextInputFormatter formatter in widget.inputFormatters) {
final bool isRepeat = value?.text == _lastFormattedUnmodifiedTextEditingValue?.text;
if (textChanged && !isRepeat && widget.inputFormatters != null && widget.inputFormatters.isNotEmpty) {
for (final TextInputFormatter formatter in widget.inputFormatters)
value = formatter.formatEditUpdate(_value, value);
}
// Always pass the text through the whitespace directionality formatter to
// maintain expected behavior with carets on trailing whitespace.
value = _whitespaceFormatter.formatEditUpdate(_value, value);
_lastFormattedValue = value;
}
// If the text has changed or the selection has changed, we should update the
// locally stored TextEditingValue to the new one.
if (!isRepeatText || !isRepeatSelection) {
_value = value;
} else if (textChanged && _lastFormattedValue != null) {
_value = _lastFormattedValue;
_updateRemoteEditingValueIfNeeded();
} else {
_value = value;
}
// Always attempt to send the value. If the value has changed, then it will send,
// otherwise, it will short-circuit.
_updateRemoteEditingValueIfNeeded();
if (textChanged && widget.onChanged != null)
widget.onChanged(value.text);
_lastFormattedUnmodifiedTextEditingValue = _receivedRemoteTextEditingValue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment