summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI
diff options
context:
space:
mode:
authorXuekun Li <i@xkun.dev>2023-05-02 20:53:59 +0800
committerSam Atkins <atkinssj@gmail.com>2023-05-05 16:48:36 +0100
commit4fb200a546ed54eb747c6e76992652d61baacb3b (patch)
tree3282e99742c07e80f90bf0754e4dc2c6b36e04b2 /Userland/Libraries/LibGUI
parent60805546bf9a1f30c24225d6e77fd60f2c440e06 (diff)
downloadserenity-4fb200a546ed54eb747c6e76992652d61baacb3b.zip
LibGUI: Fix crash on deleting word forward
<Ctrl-Del> will crash when deleting at the end of line where the next line contains only punctuation and seperator characters, because TextDocument::first_word_break_after will return a wrong index of the next word break (+1 bigger than the correct index), thus RemoveTextCommand will try to remove a out-of-bound text range causing a crash.
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r--Userland/Libraries/LibGUI/TextDocument.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp
index f3e225d025..0770cd41d6 100644
--- a/Userland/Libraries/LibGUI/TextDocument.cpp
+++ b/Userland/Libraries/LibGUI/TextDocument.cpp
@@ -791,7 +791,7 @@ TextPosition TextDocument::first_word_break_after(TextPosition const& position)
auto view_between_target_and_index = line.view().substring_view(target.column(), *index - target.column());
if (should_continue_beyond_word(view_between_target_and_index)) {
- target.set_column(*index + 1);
+ target.set_column(min(*index + 1, line.length()));
continue;
}