Bug 444691 - Word wrap prefers wrapping at CamelCase text over whitespace
Summary: Word wrap prefers wrapping at CamelCase text over whitespace
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kcoreaddons
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 5.87.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Pyne
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2021-10-31 00:13 UTC by mizusato
Modified: 2023-11-28 22:57 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
the icon (19.83 KB, image/png)
2021-10-31 00:13 UTC, mizusato
Details
comparison (44.46 KB, image/png)
2021-11-09 00:57 UTC, mizusato
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mizusato 2021-10-31 00:13:49 UTC
Created attachment 143040 [details]
the icon

SUMMARY
Weird word wrap in desktop icon label

STEPS TO REPRODUCE
I have a desktop shortcut for GNU TeXmacs. The label below its icon has a weird word wrap.

OBSERVED RESULT
Word wrap breaks "TeXmacs" into "Te" and "Xmacs".
(see the attachment)

EXPECTED RESULT
The word should not be broken.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.23.1
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
none
Comment 1 Nate Graham 2021-11-08 17:33:16 UTC
How should it be displayed instead, given the horizontal space limitations depicted in your screenshot?
Comment 2 mizusato 2021-11-09 00:57:32 UTC
Created attachment 143356 [details]
comparison
Comment 3 mizusato 2021-11-09 01:03:04 UTC
(In reply to Nate Graham from comment #1)
> How should it be displayed instead, given the horizontal space limitations
> depicted in your screenshot?

I've added a new screenshot. As you can see in the new screenshot, compared to the text "Studio Code" , the shorter text "TeXmacs" obviously does not need a word break. It was fine before I updated the OS (Archlinux) in October 31st.
Comment 4 Nate Graham 2021-11-09 16:54:18 UTC
Oh, I know what caused this: it was the new code to try to word-wrap lines at CamelCase characters. Evidently it doesn't try to wrap at whitespace first, as it probably should.

See https://invent.kde.org/plasma/plasma-desktop/-/merge_requests/554 and https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/132

Ivan, can you take a look?
Comment 5 ratijas 2021-11-09 17:01:58 UTC
What can I say, huh... The app name is a quite unusual mix of upper and lowercase letters. I can't think of any good solution to make it work for everyone. I could suggest renaming your shortcut to just "TeXmacs" (without GNU prefix to make it fit in one line), or reverting my patch for everyone.

We _could_ use some heuristics like whitelist dictionary, or not breaking on short subwords (e.g. 3 letters or less). Not idea how much better would that be in practice.
Comment 6 Nate Graham 2021-11-09 17:09:35 UTC
Is there any way we can have it prefer whitespace wrap when both whitespace and camelcase wrap possibilities exist?

I.e., we do:
   GNU
TeXmacs

instead of:
GNU Te
 Xmacs
Comment 7 Bug Janitor Service 2023-11-25 17:02:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kcoreaddons/-/merge_requests/402
Comment 8 ratijas 2023-11-28 22:57:36 UTC
Git commit d012be6e990bc8728ed0cfca2a77f6fcc0b8357b by ivan tkachenko.
Committed on 28/11/2023 at 23:51.
Pushed by ratijas into branch 'master'.

KStringHandler: Don't insert ZWSP between camelCase sub-words if string has whitespaces

Fixes application names like "GNU TeXmacs" which could have
inappropriately wrap in the middle of a stylized word.

Amends 98f5abc533c95e815742de4fe532b2920c5f6982

M  +9    -0    autotests/kstringhandlertest.cpp
M  +17   -2    src/lib/text/kstringhandler.cpp

https://invent.kde.org/frameworks/kcoreaddons/-/commit/d012be6e990bc8728ed0cfca2a77f6fcc0b8357b