Skip to content

Commit

Permalink
fix: move cursor up / down error
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasXu0 committed Nov 5, 2024
1 parent 2903792 commit 816fb3c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/src/extensions/position_extension.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import 'dart:math' as math;

import 'package:flutter/material.dart';

import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart';

enum SelectionRange {
character,
Expand Down Expand Up @@ -199,8 +198,12 @@ extension PositionExtension on Position {
// is not visible on the screen. It seems happens only if upwards is true (?)
// In this case, we can manually get the previous/next node position.
int offset = editorSelection.end.offset;
final List<int> nodePath = editorSelection.end.path;
final List<int> neighbourPath = upwards ? nodePath.previous : nodePath.next;
final Path nodePath = editorSelection.end.path;
Path neighbourPath = upwards ? nodePath.previous : nodePath.next;
if (neighbourPath.equals(nodePath)) {
final last = neighbourPath.removeLast();
neighbourPath = upwards ? neighbourPath : (neighbourPath..add(last + 1));
}
if (neighbourPath.isNotEmpty && !neighbourPath.equals(nodePath)) {
final neighbour = editorState.document.nodeAtPath(neighbourPath);
final selectable = neighbour?.selectable;
Expand Down

0 comments on commit 816fb3c

Please sign in to comment.