diff --git a/lib/src/editor/editor_component/service/shortcuts/command/remove_word_command.dart b/lib/src/editor/editor_component/service/shortcuts/command/remove_word_command.dart index 791982908..8c2a9f3d1 100644 --- a/lib/src/editor/editor_component/service/shortcuts/command/remove_word_command.dart +++ b/lib/src/editor/editor_component/service/shortcuts/command/remove_word_command.dart @@ -1,7 +1,8 @@ -import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/material.dart'; -/// Backspace key event. +import 'package:appflowy_editor/appflowy_editor.dart'; + +/// Delete key event. /// /// - support /// - desktop @@ -96,8 +97,12 @@ CommandShortcutEventHandler _deleteRightWordCommandHandler = (editorState) { return KeyEventResult.ignored; } + if (selection.isCollapsed && selection.start.offset == delta.length) { + return deleteCommand.execute(editorState); + } + // we store the position where the current word ends. - var endOfWord = selection.end.moveHorizontal( + Position? endOfWord = selection.end.moveHorizontal( editorState, forward: false, selectionRange: SelectionRange.word,