codemirror / codemirror5

In-browser code editor (version 5, legacy)
http://codemirror.net/5/
MIT License
26.82k stars 4.97k forks source link

Chinese characters TAB width is incorrect #3996

Open linlexing opened 8 years ago

linlexing commented 8 years ago

input:

a b c 中 b c 中国 b c Second row ‘b’ and ‘c’ not in the correct position

marijnh commented 8 years ago

What did you input? In your pasted content, there are no tabs, only spaces. Are you talking about the fact that the 'b c' on the second line is slightly more indented than those on the first line? If so, that's because the '中' is wider than an 'a' in your font, and CodeMirror tabs are represented as a (column-dependent) set of spaces.

linlexing commented 8 years ago

i modify the previous post,i see the textarea represented correct. -1

marijnh commented 8 years ago

Yes, that's a limitation of the way CodeMirror draws spaces. Fixing this would require measuring the content before each tab in advance, which would be prohibitively slow (by causing lots of browser relayouts).

linlexing commented 8 years ago

The last part of an endeavor is the hardest to finish.

themrmax commented 7 years ago

If you use a fixed-width Chinese font like font-family: MingLiU, it seems like the chinese characters always take up 2 spaces and the roman characters always take up one space:

image

I wonder if there is a way in the code to check if a letter is a chinese or roman letter, and in that case reduce the number of spaces to indent accordingly?