Skip to content

Conversation

ikatyang
Copy link
Member

CJK characters are considered 2-char width.

I'm not sure if this is the proper fix, but the test passed at least.


Prettier 1.7.4
Playground link

Input:

const x = ["中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文"];

Output:

const x = ["中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文", "中文"];

Expected:

const x = [
  "中文",
  "中文",
  "中文",
  "中文",
  "中文",
  "中文",
  "中文",
  "中文",
  "中文",
  "中文",
  "中文"
];

@azz
Copy link
Member

azz commented Oct 10, 2017

Generally codepoint size doesn't correlate to number of characters. Adding an exception for fill width codepoints makes sense to me.

@ikatyang ikatyang merged commit f7907b9 into prettier:master Oct 11, 2017
@ikatyang ikatyang deleted the fix/respect-cjk-width branch October 11, 2017 05:32
@lock lock bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 19, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants