Skip to content

Commit

Permalink
fix: solve the left and right key bug. (#584)
Browse files Browse the repository at this point in the history
* fix:Solve the left and right key bug. When adding an input box at the head or tail of the editor, it cannot be moved.

* feat:format
  • Loading branch information
q200892907 authored Nov 15, 2023
1 parent 009115d commit 467530d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ final CommandShortcutEvent moveCursorLeftCommand = CommandShortcutEvent(
);

CommandShortcutEventHandler _arrowLeftCommandHandler = (editorState) {
final selection = editorState.selection;
if (selection == null) {
return KeyEventResult.ignored;
}
if (isRTL(editorState)) {
editorState.moveCursorBackward(SelectionMoveRange.character);
} else {
Expand All @@ -44,6 +48,10 @@ final CommandShortcutEvent moveCursorToBeginCommand = CommandShortcutEvent(
);

CommandShortcutEventHandler _moveCursorToBeginCommandHandler = (editorState) {
final selection = editorState.selection;
if (selection == null) {
return KeyEventResult.ignored;
}
if (isRTL(editorState)) {
editorState.moveCursorBackward(SelectionMoveRange.line);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ final CommandShortcutEvent moveCursorRightCommand = CommandShortcutEvent(
);

CommandShortcutEventHandler _arrowRightCommandHandler = (editorState) {
final selection = editorState.selection;
if (selection == null) {
return KeyEventResult.ignored;
}
if (isRTL(editorState)) {
editorState.moveCursorForward(SelectionMoveRange.character);
} else {
Expand All @@ -44,6 +48,10 @@ final CommandShortcutEvent moveCursorToEndCommand = CommandShortcutEvent(
);

CommandShortcutEventHandler _moveCursorToEndCommandHandler = (editorState) {
final selection = editorState.selection;
if (selection == null) {
return KeyEventResult.ignored;
}
if (isRTL(editorState)) {
editorState.moveCursorForward(SelectionMoveRange.line);
} else {
Expand Down

0 comments on commit 467530d

Please sign in to comment.