diff --git a/lib/src/editor/editor_component/service/shortcuts/command/arrow_left_command.dart b/lib/src/editor/editor_component/service/shortcuts/command/arrow_left_command.dart index 21d8383a7..5abcf21ba 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command/arrow_left_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command/arrow_left_command.dart @@ -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 { @@ -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 { diff --git a/lib/src/editor/editor_component/service/shortcuts/command/arrow_right_command.dart b/lib/src/editor/editor_component/service/shortcuts/command/arrow_right_command.dart index 4aea0f98d..5e24e524f 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command/arrow_right_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command/arrow_right_command.dart @@ -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 { @@ -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 {