fix: on ui event reset selection type (#555)

* fix: on ui event reset selection type

* test: add test
This commit is contained in:
Mathias Mogensen 2023-10-30 04:20:42 +01:00 • committed by GitHub
commit 7336274ff9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 37 deletions

View file

@ -439,43 +439,6 @@ class _DesktopSelectionServiceWidgetState
return min.clamp(start, end);
}
/*void _showDebugLayerIfNeeded() {
remove false to show debug overlay.
if (kDebugMode && false) {
_debugOverlay?.remove();
if (offset != null) {
_debugOverlay = OverlayEntry(
builder: (context) => Positioned.fromRect(
rect: Rect.fromPoints(offset, offset.translate(20, 20)),
child: Container(
color: Colors.red.withOpacity(0.2),
),
),
);
Overlay.of(context)?.insert(_debugOverlay!);
} else if (_panStartOffset != null) {
_debugOverlay = OverlayEntry(
builder: (context) => Positioned.fromRect(
rect: Rect.fromPoints(
_panStartOffset?.translate(
0,
-(editorState.service.scrollService!.dy -
_panStartScrollDy!),
) ??
Offset.zero,
offset ?? Offset.zero),
child: Container(
color: Colors.red.withOpacity(0.2),
),
),
);
Overlay.of(context)?.insert(_debugOverlay!);
} else {
_debugOverlay = null;
}
}
}*/
@override
void registerGestureInterceptor(SelectionGestureInterceptor interceptor) {
_interceptors.add(interceptor);

View file

@ -200,6 +200,7 @@ class EditorState {
final completer = Completer<void>();
if (reason == SelectionUpdateReason.uiEvent) {
selectionType = SelectionType.inline;
WidgetsBinding.instance.addPostFrameCallback(
(timeStamp) => completer.complete(),
);
@ -208,6 +209,7 @@ class EditorState {
// broadcast to other users here
selectionExtraInfo = extraInfo;
_selectionUpdateReason = reason;
this.selection = selection;
return completer.future;