Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
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

Closed

Description

@chloerei

Text:

文字文字 English 文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字

1.2.0-beta0:

8

When mixing English and Chinese(or Japanese) with whitespace, Chinese(or Japanese) sentence can be break, instead of break in whitespace.

Browser:

文字文字 English 文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字文字

Activity

  1. winstliu commented on Nov 5, 2015

    @winstliu
    Contributor
  2. changed the title [-]Soft wrap CJK need to improve[/-] [+]Lines with mixed CJK and non-CJK wrap improperly[/+] on Nov 5, 2015
  3. lee-dohm commented on Nov 5, 2015

    @lee-dohm
    Contributor

    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:

    screen shot 2015-11-04 at 7 16 34 pm

  4. as-cii commented on Nov 5, 2015

    @as-cii
    Contributor

    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?

  5. changed the title [-]Lines with mixed CJK and non-CJK wrap improperly[/-] [+]Provide different soft-wrapping rules for CJK languages[/+] on Nov 5, 2015
  6. mandel59 commented on Nov 7, 2015

    @mandel59
  7. nathansobo commented on Nov 7, 2015

    @nathansobo
    Contributor

    @mandel59 Thanks for the link! Know any JS reference implementations?

  8. yukihop commented on Dec 9, 2015

    @yukihop

    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!

    image

    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.

  9. nathansobo commented on Dec 9, 2015

    @nathansobo
    Contributor

    @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?

  10. as-cii commented on Dec 10, 2015

    @as-cii
    Contributor

    @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 🔜.

  11. self-assigned this
    on Dec 10, 2015
  12. lock commented on Jan 18, 2019

    @lock

    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!

  13. locked as resolved and limited conversation to collaborators on Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions