From 455d733323a92d54da4c6da8158f4e5461f84213 Mon Sep 17 00:00:00 2001 From: Mathias Mogensen Date: Tue, 8 Oct 2024 20:16:37 +0200 Subject: [PATCH 1/3] fix: ctrl+delete does not delete newlines --- .../service/shortcuts/command/remove_word_command.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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..b31e7acd1 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,6 +1,7 @@ -import 'package:appflowy_editor/appflowy_editor.dart'; import 'package:flutter/material.dart'; +import 'package:appflowy_editor/appflowy_editor.dart'; + /// Backspace key event. /// /// - support @@ -96,8 +97,12 @@ CommandShortcutEventHandler _deleteRightWordCommandHandler = (editorState) { return KeyEventResult.ignored; } + if (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, From 83231dc89c7c4af937462f8443eb580b9f83acce Mon Sep 17 00:00:00 2001 From: Mathias Mogensen Date: Tue, 8 Oct 2024 20:17:56 +0200 Subject: [PATCH 2/3] fix: wrong comment --- .../service/shortcuts/command/remove_word_command.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b31e7acd1..6ea227f2e 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 @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; import 'package:appflowy_editor/appflowy_editor.dart'; -/// Backspace key event. +/// Delete key event. /// /// - support /// - desktop From 4c79dc0c7fb6dbbde10aff8be24a448e98d7b5c5 Mon Sep 17 00:00:00 2001 From: Mathias Mogensen Date: Wed, 9 Oct 2024 08:44:40 +0200 Subject: [PATCH 3/3] chore: add collapsed check --- .../service/shortcuts/command/remove_word_command.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 6ea227f2e..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 @@ -97,7 +97,7 @@ CommandShortcutEventHandler _deleteRightWordCommandHandler = (editorState) { return KeyEventResult.ignored; } - if (selection.start.offset == delta.length) { + if (selection.isCollapsed && selection.start.offset == delta.length) { return deleteCommand.execute(editorState); }