Browse Source

LibGUI: Select last word when double clicking at the end of a line

Fixes #6565.
Rafał 4 years ago
parent
commit
2d6be48c6f
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Userland/Libraries/LibGUI/TextDocument.cpp

+ 5 - 1
Userland/Libraries/LibGUI/TextDocument.cpp

@@ -628,7 +628,11 @@ TextPosition TextDocument::first_word_break_before(const TextPosition& position,
 
     auto target = position;
     auto line = this->line(target.line());
-    auto is_start_alphanumeric = isalnum(line.code_points()[target.column() - (start_at_column_before ? 1 : 0)]);
+    auto modifier = start_at_column_before ? 1 : 0;
+    if (target.column() == line.length())
+        modifier = 1;
+
+    auto is_start_alphanumeric = isalnum(line.code_points()[target.column() - modifier]);
 
     while (target.column() > 0) {
         auto prev_code_point = line.code_points()[target.column() - 1];