godot
godot copied to clipboard
Treat punctuation as words and as word separators
- fixes https://github.com/godotengine/godot/issues/92981
Treat punctuation as words and word separators. This affects behavior in TextEdit, LineEdit, and RichTextLabel for word selection and operations.
Changed a test for ui_text_backspace_word since a period after a word is now separate and won't be removed together. This matches the behavior of other editors.
- Added simple test for custom word separators from #92514.
- Added tests to prevent issues like #93618, #69254, or #75808.
Thanks for noticing and fixing this. Also for the tests :)
It looks like adding just text_edit->set_text(U"👏👏👏 👏👏"); in a test will cause a leak. See https://github.com/kitbdev/godot/actions/runs/10563094361/job/29262539610#step:17:643 for this commit https://github.com/kitbdev/godot/commit/7653fb6a8dae12c1be27162e5474b6b0a279231f.
I guess TextEdit isn't properly cleaning up when it gets deleted?
It looks like adding just text_edit->set_text(U"👏👏👏 👏👏"); in a test will cause a leak.
Are you referring to /lib/x86_64-linux-gnu/libfontconfig.so.1+ leak? This is an issue with the external library (👏 is not part of the editor fonts, so it's trying to load system font as fallback). The library is not part of Godot but part of Linux distro, so I'm not sure if we can do anything with it. Probably should be ignored, or we can add a subset of emoji font specifically for tests.
Thanks! I can remove the emoji test for now, it's not that important for this pr.
The other languages I was using were also causing issues, so I removed that test from this PR.
Actually I don't think this gives enough information when trying to select a word at its edges, since punctuation should have lower priority but there is no way to convey that in this method.
Ex. test==value when the cursor is before or after the == it should select the word next to it, but the word breaks returned here (0,4,4,6,6,11) won't tell you which way to select.
I'm guessing I'll need to add a new method or something.
Marking as draft for now.