Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f3b6505f
Unverified
Commit
f3b6505f
authored
Jan 03, 2024
by
LongCatIsLooong
Committed by
GitHub
Jan 03, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 139196 selection OOB (#140300)
Fixes #139196
parent
530b766f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+10
-1
editable_text_shortcuts_test.dart
...es/flutter/test/widgets/editable_text_shortcuts_test.dart
+8
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
f3b6505f
...
@@ -4742,6 +4742,15 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
...
@@ -4742,6 +4742,15 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
}
}
void
_updateSelection
(
UpdateSelectionIntent
intent
)
{
void
_updateSelection
(
UpdateSelectionIntent
intent
)
{
assert
(
intent
.
newSelection
.
start
<=
intent
.
currentTextEditingValue
.
text
.
length
,
'invalid selection:
${intent.newSelection}
: it must not exceed the current text length
${intent.currentTextEditingValue.text.length}
'
,
);
assert
(
intent
.
newSelection
.
end
<=
intent
.
currentTextEditingValue
.
text
.
length
,
'invalid selection:
${intent.newSelection}
: it must not exceed the current text length
${intent.currentTextEditingValue.text.length}
'
,
);
bringIntoView
(
intent
.
newSelection
.
extent
);
bringIntoView
(
intent
.
newSelection
.
extent
);
userUpdateTextEditingValue
(
userUpdateTextEditingValue
(
intent
.
currentTextEditingValue
.
copyWith
(
selection:
intent
.
newSelection
),
intent
.
currentTextEditingValue
.
copyWith
(
selection:
intent
.
newSelection
),
...
@@ -5645,7 +5654,7 @@ class _UpdateTextSelectionVerticallyAction<T extends DirectionalCaretMovementInt
...
@@ -5645,7 +5654,7 @@ class _UpdateTextSelectionVerticallyAction<T extends DirectionalCaretMovementInt
:
intent
.
forward
?
currentRun
.
moveNext
()
:
currentRun
.
movePrevious
();
:
intent
.
forward
?
currentRun
.
moveNext
()
:
currentRun
.
movePrevious
();
final
TextPosition
newExtent
=
shouldMove
final
TextPosition
newExtent
=
shouldMove
?
currentRun
.
current
?
currentRun
.
current
:
intent
.
forward
?
TextPosition
(
offset:
state
.
_
value
.
text
.
length
)
:
const
TextPosition
(
offset:
0
);
:
intent
.
forward
?
TextPosition
(
offset:
value
.
text
.
length
)
:
const
TextPosition
(
offset:
0
);
final
TextSelection
newSelection
=
collapseSelection
final
TextSelection
newSelection
=
collapseSelection
?
TextSelection
.
fromPosition
(
newExtent
)
?
TextSelection
.
fromPosition
(
newExtent
)
:
value
.
selection
.
extendTo
(
newExtent
);
:
value
.
selection
.
extendTo
(
newExtent
);
...
...
packages/flutter/test/widgets/editable_text_shortcuts_test.dart
View file @
f3b6505f
...
@@ -1660,6 +1660,14 @@ void main() {
...
@@ -1660,6 +1660,14 @@ void main() {
);
);
}
}
},
variant:
TargetPlatformVariant
.
all
());
},
variant:
TargetPlatformVariant
.
all
());
// Regression test for https://github.com/flutter/flutter/issues/139196.
testWidgets
(
'does not create invalid selection'
,
(
WidgetTester
tester
)
async
{
controller
.
value
=
const
TextEditingValue
(
text:
'A'
,
selection:
TextSelection
.
collapsed
(
offset:
1
));
await
tester
.
pumpWidget
(
buildEditableText
());
controller
.
value
=
const
TextEditingValue
(
text:
'AA'
,
selection:
TextSelection
.
collapsed
(
offset:
2
));
await
sendKeyCombination
(
tester
,
const
SingleActivator
(
LogicalKeyboardKey
.
arrowDown
));
},
variant:
TargetPlatformVariant
.
all
());
});
});
});
});
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment