From 138d89e5fc5715d24bdd95ef4b341aff0de77184 Mon Sep 17 00:00:00 2001 From: Xin Yao Date: Fri, 6 Aug 2021 00:53:41 -0700 Subject: [PATCH] Fix caret display when cursor on embed line --- lib/src/widgets/proxy.dart | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/proxy.dart b/lib/src/widgets/proxy.dart index 8a04c4e1..85a2a613 100644 --- a/lib/src/widgets/proxy.dart +++ b/lib/src/widgets/proxy.dart @@ -103,8 +103,12 @@ class RenderEmbedProxy extends RenderProxyBox implements RenderContentProxyBox { @override Offset getOffsetForCaret(TextPosition position, Rect? caretPrototype) { - assert(position.offset <= 1 && position.offset >= 0); - return position.offset == 0 ? Offset.zero : Offset(size.width, 0); + assert(position.offset == 1 || position.offset == 0); + return position.offset == 0 + ? Offset.zero + : Offset( + size.width - (caretPrototype == null ? 0 : caretPrototype.width), + 0); } @override