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
e170ea52
Unverified
Commit
e170ea52
authored
Apr 23, 2021
by
Ren You
Committed by
GitHub
Apr 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "[RenderEditable] Dont paint caret when selection is invalid (#79607)" (#81076)
This reverts commit
0f8148ec
.
parent
c26ed03c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
50 deletions
+4
-50
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+4
-5
editable_test.dart
packages/flutter/test/rendering/editable_test.dart
+0
-45
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
e170ea52
...
...
@@ -3703,10 +3703,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
_clipRectLayer
=
null
;
_paintContents
(
context
,
offset
);
}
final
TextSelection
?
selection
=
this
.
selection
;
if
(
selection
!=
null
)
{
_paintHandleLayers
(
context
,
getEndpointsForSelection
(
selection
));
}
_paintHandleLayers
(
context
,
getEndpointsForSelection
(
selection
!));
}
ClipRectLayer
?
_clipRectLayer
;
...
...
@@ -4063,7 +4060,9 @@ class _FloatingCursorPainter extends RenderEditablePainter {
assert
(
renderEditable
!=
null
);
final
TextSelection
?
selection
=
renderEditable
.
selection
;
if
(
selection
==
null
||
!
selection
.
isCollapsed
||
!
selection
.
isValid
)
// TODO(LongCatIsLooong): skip painting the caret when the selection is
// (-1, -1).
if
(
selection
==
null
||
!
selection
.
isCollapsed
)
return
;
final
Rect
?
floatingCursorRect
=
this
.
floatingCursorRect
;
...
...
packages/flutter/test/rendering/editable_test.dart
View file @
e170ea52
...
...
@@ -412,51 +412,6 @@ void main() {
expect
(
editable
,
paintsExactlyCountTimes
(
#drawRect
,
1
));
});
test
(
'does not paint the caret when selection is null'
,
()
async
{
final
TextSelectionDelegate
delegate
=
FakeEditableTextState
();
final
ValueNotifier
<
bool
>
showCursor
=
ValueNotifier
<
bool
>(
true
);
final
RenderEditable
editable
=
RenderEditable
(
backgroundCursorColor:
Colors
.
grey
,
selectionColor:
Colors
.
black
,
paintCursorAboveText:
true
,
textDirection:
TextDirection
.
ltr
,
cursorColor:
Colors
.
red
,
showCursor:
showCursor
,
offset:
ViewportOffset
.
zero
(),
textSelectionDelegate:
delegate
,
text:
const
TextSpan
(
text:
'test'
,
style:
TextStyle
(
height:
1.0
,
fontSize:
10.0
,
fontFamily:
'Ahem'
,
),
),
startHandleLayerLink:
LayerLink
(),
endHandleLayerLink:
LayerLink
(),
selection:
const
TextSelection
.
collapsed
(
offset:
2
,
affinity:
TextAffinity
.
upstream
,
),
);
layout
(
editable
);
expect
(
editable
,
paints
..
paragraph
()
// Red collapsed cursor is painted, not a selection box.
..
rect
(
color:
Colors
.
red
[
500
]),
);
// Let the RenderEditable paint again. Setting the selection to null should
// prevent the caret from being painted.
editable
.
selection
=
null
;
// Still paints the paragraph.
expect
(
editable
,
paints
..
paragraph
());
// No longer paints the caret.
expect
(
editable
,
isNot
(
paints
..
rect
(
color:
Colors
.
red
[
500
])));
});
test
(
'selects correct place with offsets'
,
()
{
const
String
text
=
'test
\n
test'
;
final
TextSelectionDelegate
delegate
=
FakeEditableTextState
()
...
...
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