From a0072f422a11229d4b35308e7aa6badd23d08ba6 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 5 Sep 2024 12:10:57 -0400 Subject: [PATCH] LibWeb: Support jumping across word boundaries in text nodes This also supports holding shift to modify the selection. --- Userland/Libraries/LibWeb/Page/EventHandler.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/Page/EventHandler.cpp b/Userland/Libraries/LibWeb/Page/EventHandler.cpp index d3cd21aca52..a78f4afabad 100644 --- a/Userland/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Userland/Libraries/LibWeb/Page/EventHandler.cpp @@ -931,9 +931,15 @@ bool EventHandler::handle_keydown(UIEvents::KeyCode key, u32 modifiers, u32 code if (key == UIEvents::KeyCode::Key_Left || key == UIEvents::KeyCode::Key_Right) { auto increment_or_decrement_cursor = [&]() { + if ((modifiers & UIEvents::Mod_PlatformWordJump) == 0) { + if (key == UIEvents::KeyCode::Key_Left) + return document->decrement_cursor_position_offset(); + return document->increment_cursor_position_offset(); + } + if (key == UIEvents::KeyCode::Key_Left) - return document->decrement_cursor_position_offset(); - return document->increment_cursor_position_offset(); + return document->decrement_cursor_position_to_previous_word(); + return document->increment_cursor_position_to_next_word(); }; if ((modifiers & UIEvents::Mod_Shift) == 0) {