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

LibGUI: Fix stuck on deleting word backward

<Ctrl-Backspace> will stuck when deleting at the end of line
which contains only one single character. When finding the
previous word break position starting at column 0 in
TextDocument::first_word_break_before, the code enters an
infinite while loop. The early return should simply fix this.
This commit is contained in:
Xuekun Li 2023-05-02 20:52:30 +08:00 committed by Sam Atkins
parent 5c29b45d1d
commit 60805546bf

View file

@ -754,6 +754,9 @@ TextPosition TextDocument::first_word_break_before(TextPosition const& position,
target.set_column(target.column() - modifier);
if (target.column() == 0)
return target;
while (target.column() < line.length()) {
if (auto index = Unicode::previous_word_segmentation_boundary(line.view(), target.column()); index.has_value()) {
auto view_between_target_and_index = line.view().substring_view(*index, target.column() - *index);