Skip to content

Commit c63831d

Browse files
authored
Fix incorrect double to int cast, and guard against optional parent (singerdmx#239)
1 parent 2b9d6bd commit c63831d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/src/models/documents/nodes/node.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ abstract class Node extends LinkedListEntry<Node> {
5353

5454
/// Offset in characters of this node in the document.
5555
int get documentOffset {
56+
if (parent == null) {
57+
return offset;
58+
}
5659
final parentOffset = (parent is! Root) ? parent!.documentOffset : 0;
5760
return parentOffset + offset;
5861
}

lib/src/widgets/text_line.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,11 @@ class RenderEditableTextLine extends RenderEditableBox {
625625
final verticalPadding = _resolvedPadding!.top + _resolvedPadding!.bottom;
626626
final leadingWidth = _leading == null
627627
? 0
628-
: _leading!.getMinIntrinsicWidth(height - verticalPadding) as int;
628+
: _leading!.getMinIntrinsicWidth(height - verticalPadding).floor();
629629
final bodyWidth = _body == null
630630
? 0
631631
: _body!.getMinIntrinsicWidth(math.max(0, height - verticalPadding))
632-
as int;
632+
.floor();
633633
return horizontalPadding + leadingWidth + bodyWidth;
634634
}
635635

@@ -640,11 +640,11 @@ class RenderEditableTextLine extends RenderEditableBox {
640640
final verticalPadding = _resolvedPadding!.top + _resolvedPadding!.bottom;
641641
final leadingWidth = _leading == null
642642
? 0
643-
: _leading!.getMaxIntrinsicWidth(height - verticalPadding) as int;
643+
: _leading!.getMaxIntrinsicWidth(height - verticalPadding).ceil();
644644
final bodyWidth = _body == null
645645
? 0
646646
: _body!.getMaxIntrinsicWidth(math.max(0, height - verticalPadding))
647-
as int;
647+
.ceil();
648648
return horizontalPadding + leadingWidth + bodyWidth;
649649
}
650650

0 commit comments

Comments
 (0)