You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Provide different soft-wrapping rules for CJK languages #9447
It looks like it is only lines that contain both CJK and non-CJK that show the issue. If I shrink the window even further, the all CJK line wraps as expected:
The problem here lies in how soft-wrapping changes depending on the language. #9162 only addressed the rendering part of it, which was causing issues because of the amount of space characters were occupying. The way word-wrapping works as of now is that we will soft-wrap if we manage to match a space before the hypothetical hard-wrap position: if we do, we break the line in two, otherwise we perform an hard-wrap at the desired position.
An hypothetical solution to this will need to take into account the language, because as far as I know, each language has its own soft-wrapping rules. There's a good article on Wikipedia which explains this in greater detail.
@nathansobo: our current solution was a great leap compared to the past, but I feel like I could put some effort into polishing this following the aforementioned rules. What do you think?
Currently, this bug is making this editor nearly useless for editing CJK markdown documents, HTML and such, which naturally involve a small number of spaces and long CJK strings jumbled together. Atom often tries to break lines at the second column!
And editing markdown is one of the fields Atom should be exceptionally good at.
So is it possible to add a mode to suppress "per-word" soft wrapping altogether (even for English words)? I guess that's essentially the cause of this bug, and removing it should quickly fix this problem.
While word processors such as Word definitely need complex wrapping algorithm suggested here, I doubt editors like Atom need this kind of sophisticated line-breaking algorithm, which could potentially slow things down. The goal of Atom is not to replace Word or InDesign.
At least in Japan, most popular domestic editors (such as Hidemaru) do not respect line-breaking rules at all by default. They simply break lines everywhere, even in the middle of an English word. The users of such editors don't care if commas and closing brackets come at the beginning of a line. As a native speaker of Japanese, I'd say that's the preferred behavior when I feel like using Atom. Seeing split English words is much more tolerable than seeing soft-warp happening at the second column.
@as-cii Seems like we could detect CJK characters in our soft-wrap code and just break at the preferred wrap boundary instead of at whitespace if there are any in the line. Thoughts?
@nathansobo: interesting, using Unicode's standard line breaking algorithm seemed quite tempting to me, although I am not sure how long it could take to implement it or to integrate an existing package (e.g line-break) with Atom.
I guess that detecting whether the character at the preferred wrap boundary is CJK could be fine. Opening a PR for this 🔜.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
Activity
winstliu commentedon Nov 5, 2015
/cc @as-cii
[-]Soft wrap CJK need to improve[/-][+]Lines with mixed CJK and non-CJK wrap improperly[/+]lee-dohm commentedon Nov 5, 2015
It looks like it is only lines that contain both CJK and non-CJK that show the issue. If I shrink the window even further, the all CJK line wraps as expected:
as-cii commentedon Nov 5, 2015
The problem here lies in how soft-wrapping changes depending on the language. #9162 only addressed the rendering part of it, which was causing issues because of the amount of space characters were occupying. The way word-wrapping works as of now is that we will soft-wrap if we manage to match a space before the hypothetical hard-wrap position: if we do, we break the line in two, otherwise we perform an hard-wrap at the desired position.
An hypothetical solution to this will need to take into account the language, because as far as I know, each language has its own soft-wrapping rules. There's a good article on Wikipedia which explains this in greater detail.
@nathansobo: our current solution was a great leap compared to the past, but I feel like I could put some effort into polishing this following the aforementioned rules. What do you think?
[-]Lines with mixed CJK and non-CJK wrap improperly[/-][+]Provide different soft-wrapping rules for CJK languages[/+]mandel59 commentedon Nov 7, 2015
Unicode provides Unicode Line Breaking Algorithm.
nathansobo commentedon Nov 7, 2015
@mandel59 Thanks for the link! Know any JS reference implementations?
mandel59 commentedon Nov 7, 2015
I found https://github.com/devongovett/linebreak
wonderbeyond commentedon Nov 9, 2015
https://github.com/devongovett/linebreak seems good!
yukihop commentedon Dec 9, 2015
Currently, this bug is making this editor nearly useless for editing CJK markdown documents, HTML and such, which naturally involve a small number of spaces and long CJK strings jumbled together. Atom often tries to break lines at the second column!
And editing markdown is one of the fields Atom should be exceptionally good at.
So is it possible to add a mode to suppress "per-word" soft wrapping altogether (even for English words)? I guess that's essentially the cause of this bug, and removing it should quickly fix this problem.
While word processors such as Word definitely need complex wrapping algorithm suggested here, I doubt editors like Atom need this kind of sophisticated line-breaking algorithm, which could potentially slow things down. The goal of Atom is not to replace Word or InDesign.
At least in Japan, most popular domestic editors (such as Hidemaru) do not respect line-breaking rules at all by default. They simply break lines everywhere, even in the middle of an English word. The users of such editors don't care if commas and closing brackets come at the beginning of a line. As a native speaker of Japanese, I'd say that's the preferred behavior when I feel like using Atom. Seeing split English words is much more tolerable than seeing soft-warp happening at the second column.
nathansobo commentedon Dec 9, 2015
@as-cii Seems like we could detect CJK characters in our soft-wrap code and just break at the preferred wrap boundary instead of at whitespace if there are any in the line. Thoughts?
as-cii commentedon Dec 10, 2015
@nathansobo: interesting, using Unicode's standard line breaking algorithm seemed quite tempting to me, although I am not sure how long it could take to implement it or to integrate an existing package (e.g line-break) with Atom.
I guess that detecting whether the character at the preferred wrap boundary is CJK could be fine. Opening a PR for this 🔜.
lock commentedon Jan 18, 2019
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!