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
5736def3
Unverified
Commit
5736def3
authored
Jun 09, 2020
by
Jason Simmons
Committed by
GitHub
Jun 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle selection ranges where getBoxesForSelection returns an empty list (#59014)
parent
22ea668f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+4
-2
editable_test.dart
packages/flutter/test/rendering/editable_test.dart
+19
-0
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
5736def3
...
...
@@ -1462,13 +1462,15 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
final
Offset
paintOffset
=
_paintOffset
;
if
(
selection
.
isCollapsed
)
{
final
List
<
ui
.
TextBox
>
boxes
=
selection
.
isCollapsed
?
<
ui
.
TextBox
>[]
:
_textPainter
.
getBoxesForSelection
(
selection
);
if
(
boxes
.
isEmpty
)
{
// TODO(mpcomplete): This doesn't work well at an RTL/LTR boundary.
final
Offset
caretOffset
=
_textPainter
.
getOffsetForCaret
(
selection
.
extent
,
_caretPrototype
);
final
Offset
start
=
Offset
(
0.0
,
preferredLineHeight
)
+
caretOffset
+
paintOffset
;
return
<
TextSelectionPoint
>[
TextSelectionPoint
(
start
,
null
)];
}
else
{
final
List
<
ui
.
TextBox
>
boxes
=
_textPainter
.
getBoxesForSelection
(
selection
);
final
Offset
start
=
Offset
(
boxes
.
first
.
start
,
boxes
.
first
.
bottom
)
+
paintOffset
;
final
Offset
end
=
Offset
(
boxes
.
last
.
end
,
boxes
.
last
.
bottom
)
+
paintOffset
;
return
<
TextSelectionPoint
>[
...
...
packages/flutter/test/rendering/editable_test.dart
View file @
5736def3
...
...
@@ -796,4 +796,23 @@ void main() {
await
simulateKeyUpEvent
(
LogicalKeyboardKey
.
delete
,
platform:
'android'
);
expect
(
delegate
.
textEditingValue
.
text
,
''
);
},
skip:
kIsWeb
);
// Key simulation doesn't work on web.
test
(
'getEndpointsForSelection handles empty characters'
,
()
{
final
TextSelectionDelegate
delegate
=
FakeEditableTextState
();
final
RenderEditable
editable
=
RenderEditable
(
// This is a Unicode left-to-right mark character that will not render
// any glyphs.
text:
const
TextSpan
(
text:
'
\
u200e'
),
textAlign:
TextAlign
.
start
,
textDirection:
TextDirection
.
ltr
,
offset:
ViewportOffset
.
zero
(),
textSelectionDelegate:
delegate
,
startHandleLayerLink:
LayerLink
(),
endHandleLayerLink:
LayerLink
(),
);
editable
.
layout
(
BoxConstraints
.
loose
(
const
Size
(
100
,
100
)));
final
List
<
TextSelectionPoint
>
endpoints
=
editable
.
getEndpointsForSelection
(
const
TextSelection
(
baseOffset:
0
,
extentOffset:
1
));
expect
(
endpoints
[
0
].
point
.
dx
,
0
);
});
}
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