1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

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.
This commit is contained in:
Xuekun Li 2023-05-02 20:53:59 +08:00 committed by Sam Atkins
parent 60805546bf
commit 4fb200a546

View file

@ -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;
}