Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ class _MarkdownDocumentViewState extends State<MarkdownDocumentView> {
oldWidget.selectable != widget.selectable) {
_cachedBlockRows.clear();
}
_syncSelectionParticipant(participantChanged: true);
// Only notify on document changes: the registrar's refresh rebuilds this
// widget, so an unconditional notification never lets frames settle.
_syncSelectionParticipant(
participantChanged: !identical(oldWidget.document, widget.document),
);
}

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,13 @@ Offset _characterCenter(
return renderBox.localToGlobal(box.center);
}

Future<void> _rightClick(
WidgetTester tester,
Offset position, {
bool settle = true,
}) async {
Future<void> _rightClick(WidgetTester tester, Offset position) async {
await tester.tapAt(
position,
buttons: kSecondaryMouseButton,
kind: PointerDeviceKind.mouse,
);
if (settle) {
await tester.pumpAndSettle();
} else {
await tester.pump();
}
await tester.pumpAndSettle();
}

Future<void> _doubleClick(WidgetTester tester, Offset position) async {
Expand Down Expand Up @@ -166,12 +158,10 @@ void main() {
),
);

await tester.pump();
await tester.pumpAndSettle();
await _rightClick(
tester,
_characterCenter(tester, containing: 'Hello', character: 'v'),
// MixinSelectionArea keeps scheduling frames, so it never settles.
settle: false,
);
expect(selection.selectedPlainText, 'brave');
expect(_menu, findsOneWidget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7878,6 +7878,36 @@ Tables support varying alignments, complex cell contents, and inline styles.
expect(selectionRects, isNotEmpty);
});

testWidgets('MixinSelectionArea with MarkdownWidget settles', (tester) async {
final selectionController = MarkdownSelectionController();
addTearDown(selectionController.dispose);

Widget buildApp(String data) {
return MaterialApp(
home: Scaffold(
body: MixinSelectionArea(
controller: selectionController,
child: MarkdownWidget(data: data, useColumn: true),
),
),
);
}

await tester.pumpWidget(buildApp('Hello brave world'));
await tester.pumpAndSettle();

expect(tester.binding.hasScheduledFrame, isFalse);
selectionController.selectAll();
expect(selectionController.selectedPlainText, 'Hello brave world');

await tester.pumpWidget(buildApp('Hello new world'));
await tester.pumpAndSettle();

expect(tester.binding.hasScheduledFrame, isFalse);
selectionController.selectAll();
expect(selectionController.selectedPlainText, 'Hello new world');
});

testWidgets('MixinSelectionArea exposes public selectable widgets',
(tester) async {
final selectionController = MarkdownSelectionController();
Expand Down
Loading