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:
parent
5c29b45d1d
commit
60805546bf
1 changed files with 3 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue