mirror of
https://github.com/AppFlowy-IO/AppFlowy
synced 2026-05-24 09:38:25 +00:00
fix: fix crash when selecting the last node
This commit is contained in:
parent
dc018bc7e4
commit
2f84d7e54e
1 changed files with 5 additions and 9 deletions
|
|
@ -313,13 +313,9 @@ class _FlowySelectionState extends State<FlowySelection>
|
||||||
panStartOffsetWithScrollDyGap.translate(0, panStartScrollDy! - dy);
|
panStartOffsetWithScrollDyGap.translate(0, panStartScrollDy! - dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
final sortedNodes =
|
final first =
|
||||||
editorState.document.root.children.toList(growable: false);
|
_lowerBoundInDocument(panStartOffsetWithScrollDyGap).selectable;
|
||||||
final first = _lowerBound(
|
final last = _upperBoundInDocument(panEndOffset!).selectable;
|
||||||
sortedNodes, panStartOffsetWithScrollDyGap, 0, sortedNodes.length)
|
|
||||||
.selectable;
|
|
||||||
final last = _upperBound(sortedNodes, panEndOffset!, 0, sortedNodes.length)
|
|
||||||
.selectable;
|
|
||||||
|
|
||||||
// compute the selection in range.
|
// compute the selection in range.
|
||||||
if (first != null && last != null) {
|
if (first != null && last != null) {
|
||||||
|
|
@ -518,13 +514,13 @@ class _FlowySelectionState extends State<FlowySelection>
|
||||||
Node _lowerBoundInDocument(Offset offset) {
|
Node _lowerBoundInDocument(Offset offset) {
|
||||||
final sortedNodes =
|
final sortedNodes =
|
||||||
editorState.document.root.children.toList(growable: false);
|
editorState.document.root.children.toList(growable: false);
|
||||||
return _lowerBound(sortedNodes, offset, 0, sortedNodes.length);
|
return _lowerBound(sortedNodes, offset, 0, sortedNodes.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Node _upperBoundInDocument(Offset offset) {
|
Node _upperBoundInDocument(Offset offset) {
|
||||||
final sortedNodes =
|
final sortedNodes =
|
||||||
editorState.document.root.children.toList(growable: false);
|
editorState.document.root.children.toList(growable: false);
|
||||||
return _upperBound(sortedNodes, offset, 0, sortedNodes.length);
|
return _upperBound(sortedNodes, offset, 0, sortedNodes.length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: Supports multi-level nesting,
|
/// TODO: Supports multi-level nesting,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue