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
c5866c5e
Unverified
Commit
c5866c5e
authored
Jul 29, 2021
by
Justin McCandless
Committed by
GitHub
Jul 29, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicitly set affinity when moving left/right by line (#87133)
parent
a7899c19
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
0 deletions
+9
-0
editable.dart
packages/flutter/lib/src/rendering/editable.dart
+2
-0
editable_test.dart
packages/flutter/test/rendering/editable_test.dart
+7
-0
No files found.
packages/flutter/lib/src/rendering/editable.dart
View file @
c5866c5e
...
@@ -1965,6 +1965,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
...
@@ -1965,6 +1965,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
final
TextSelection
selectedLine
=
_getLineAtOffset
(
TextPosition
(
offset:
startPoint
));
final
TextSelection
selectedLine
=
_getLineAtOffset
(
TextPosition
(
offset:
startPoint
));
final
TextSelection
nextSelection
=
TextSelection
.
collapsed
(
final
TextSelection
nextSelection
=
TextSelection
.
collapsed
(
offset:
selectedLine
.
baseOffset
,
offset:
selectedLine
.
baseOffset
,
affinity:
TextAffinity
.
downstream
,
);
);
_setSelection
(
nextSelection
,
cause
);
_setSelection
(
nextSelection
,
cause
);
...
@@ -2051,6 +2052,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
...
@@ -2051,6 +2052,7 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin,
final
TextSelection
selectedLine
=
_getLineAtOffset
(
TextPosition
(
offset:
startPoint
));
final
TextSelection
selectedLine
=
_getLineAtOffset
(
TextPosition
(
offset:
startPoint
));
final
TextSelection
nextSelection
=
TextSelection
.
collapsed
(
final
TextSelection
nextSelection
=
TextSelection
.
collapsed
(
offset:
selectedLine
.
extentOffset
,
offset:
selectedLine
.
extentOffset
,
affinity:
TextAffinity
.
upstream
,
);
);
_setSelection
(
nextSelection
,
cause
);
_setSelection
(
nextSelection
,
cause
);
...
...
packages/flutter/test/rendering/editable_test.dart
View file @
c5866c5e
...
@@ -925,6 +925,7 @@ void main() {
...
@@ -925,6 +925,7 @@ void main() {
editable
.
moveSelectionRightByLine
(
SelectionChangedCause
.
keyboard
);
editable
.
moveSelectionRightByLine
(
SelectionChangedCause
.
keyboard
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
baseOffset
,
13
);
expect
(
currentSelection
.
baseOffset
,
13
);
expect
(
currentSelection
.
affinity
,
TextAffinity
.
upstream
);
// RenderEditable relies on its parent that passes onSelectionChanged to set
// RenderEditable relies on its parent that passes onSelectionChanged to set
// the selection.
// the selection.
...
@@ -933,21 +934,25 @@ void main() {
...
@@ -933,21 +934,25 @@ void main() {
editable
.
moveSelectionRightByLine
(
SelectionChangedCause
.
keyboard
);
editable
.
moveSelectionRightByLine
(
SelectionChangedCause
.
keyboard
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
baseOffset
,
13
);
expect
(
currentSelection
.
baseOffset
,
13
);
expect
(
currentSelection
.
affinity
,
TextAffinity
.
upstream
);
// Move back to the start of the line.
// Move back to the start of the line.
editable
.
moveSelectionLeftByLine
(
SelectionChangedCause
.
keyboard
);
editable
.
moveSelectionLeftByLine
(
SelectionChangedCause
.
keyboard
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
baseOffset
,
0
);
expect
(
currentSelection
.
baseOffset
,
0
);
expect
(
currentSelection
.
affinity
,
TextAffinity
.
downstream
);
// Trying moveSelectionLeftByLine does nothing at the leftmost of the field.
// Trying moveSelectionLeftByLine does nothing at the leftmost of the field.
editable
.
moveSelectionLeftByLine
(
SelectionChangedCause
.
keyboard
);
editable
.
moveSelectionLeftByLine
(
SelectionChangedCause
.
keyboard
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
baseOffset
,
0
);
expect
(
currentSelection
.
baseOffset
,
0
);
expect
(
currentSelection
.
affinity
,
TextAffinity
.
downstream
);
// Move the selection to the empty line.
// Move the selection to the empty line.
editable
.
moveSelectionRightByLine
(
SelectionChangedCause
.
keyboard
);
editable
.
moveSelectionRightByLine
(
SelectionChangedCause
.
keyboard
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
baseOffset
,
13
);
expect
(
currentSelection
.
baseOffset
,
13
);
expect
(
currentSelection
.
affinity
,
TextAffinity
.
upstream
);
editable
.
moveSelectionRight
(
SelectionChangedCause
.
keyboard
);
editable
.
moveSelectionRight
(
SelectionChangedCause
.
keyboard
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
baseOffset
,
14
);
expect
(
currentSelection
.
baseOffset
,
14
);
...
@@ -957,9 +962,11 @@ void main() {
...
@@ -957,9 +962,11 @@ void main() {
editable
.
moveSelectionLeftByLine
(
SelectionChangedCause
.
keyboard
);
editable
.
moveSelectionLeftByLine
(
SelectionChangedCause
.
keyboard
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
baseOffset
,
14
);
expect
(
currentSelection
.
baseOffset
,
14
);
expect
(
currentSelection
.
affinity
,
TextAffinity
.
downstream
);
editable
.
moveSelectionRightByLine
(
SelectionChangedCause
.
keyboard
);
editable
.
moveSelectionRightByLine
(
SelectionChangedCause
.
keyboard
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
isCollapsed
,
true
);
expect
(
currentSelection
.
baseOffset
,
14
);
expect
(
currentSelection
.
baseOffset
,
14
);
expect
(
currentSelection
.
affinity
,
TextAffinity
.
downstream
);
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61021
},
skip:
isBrowser
);
// https://github.com/flutter/flutter/issues/61021
test
(
'arrow keys and delete handle simple text correctly'
,
()
async
{
test
(
'arrow keys and delete handle simple text correctly'
,
()
async
{
...
...
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