From c919703b8b2f5f319b99399b16c46105eaba8171 Mon Sep 17 00:00:00 2001 From: AtlasAutocode Date: Sat, 13 Jul 2024 12:10:11 -0600 Subject: [PATCH] Fix: Up arrow with large fonts, assert at start of text for indent --- lib/src/widgets/quill/text_block.dart | 2 +- lib/src/widgets/quill/text_line.dart | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/widgets/quill/text_block.dart b/lib/src/widgets/quill/text_block.dart index c0b6b187..e3de668c 100644 --- a/lib/src/widgets/quill/text_block.dart +++ b/lib/src/widgets/quill/text_block.dart @@ -691,7 +691,7 @@ class RenderEditableTextBlock extends RenderEditableContainerBox @override TextPosition globalToLocalPosition(TextPosition position) { - assert(container.containsOffset(position.offset), + assert(container.containsOffset(position.offset) || container.length == 0, 'The provided text position is not in the current node'); return TextPosition( offset: position.offset - container.documentOffset, diff --git a/lib/src/widgets/quill/text_line.dart b/lib/src/widgets/quill/text_line.dart index c3dbb146..31db5211 100644 --- a/lib/src/widgets/quill/text_line.dart +++ b/lib/src/widgets/quill/text_line.dart @@ -921,7 +921,13 @@ class RenderEditableTextLine extends RenderEditableBox { @override TextPosition? getPositionAbove(TextPosition position) { - return _getPosition(position, -0.5); + /// Move up by fraction of the default font height, larger font sizes need larger offset + for ( var offset = -0.5; ; offset -= 0.25 ) { + final pos = _getPosition(position, offset); + if ( pos != position || offset <= -2.0 ) { + return pos; + } + } } @override