Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Word wrap get wrong line length while U+2018, U+2019, U+201C, U+201D are present #70627

Closed
qaqz111 opened this issue Mar 16, 2019 · 6 comments
Closed
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-wrapping Editor line wrapping issues feature-request Request for new features or functionality

Comments

@qaqz111
Copy link

qaqz111 commented Mar 16, 2019

Issue Type: Bug

Word wrap get wrong line length calculated while these characters are present in line:
U+2018[](Left Single Quotation Mark)
U+2019[](Right Single Quotation Mark)
U+201C[](Left Double Quotation Mark)
U+201D[](Right Double Quotation Mark)

These characters are wide characters and should take 2 alphabet characters' width, also known as fullwidth characters, they are different from U+0027' and U+0022["](Quotation Mark) which are narrow characters(halfwidth characters), see references below.

It looks like VSCode calculated these characters as narrow, thus while a long line with 2 or more these characters before wrap position, there will be 1 or more characters stay on the original line so that they are overlapped and covered by scroll bar.

Steps to reproduce this issue:

  1. Press Ctrl+N to create a new file
  2. Press Alt+Z to enable word wrap
  3. Input some text like ABCDEFGHIJKLMNOPQRSTUVWXYZ
  4. Paste the character above(anyone of them) multiple times at line beginning until line end reaches scroll bar
  5. Keep pasting and you can see that the characters at line end was covered by scroll bar
  6. Press Ctrl+F and toggle replace mode, replace the pasted character with 2 ASCII characters, you can see that the word wrap is working correctly now and no character is overlapped by scroll bar

References: Unicode® Standard Annex #11 - EAST ASIAN WIDTH
http://www.unicode.org/reports/tr11/
https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt

And, my system is Windows10 x64 Simplified Chinese, I don't know if this is a bug under other systems of other language.

VS Code version: Code 1.32.3 (a3db5be, 2019-03-14T23:43:35.476Z)
OS version: Windows_NT x64 10.0.17763

@vscodebot
Copy link

vscodebot bot commented Mar 16, 2019

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@qaqz111
Copy link
Author

qaqz111 commented Mar 17, 2019

No, this issue is related to wrong character width calculating which is different from #33236, 2 issues may be occurred at same time.

@vscodebot vscodebot bot removed the new release label Mar 19, 2019
@msftrncs
Copy link

I don't think this has anything to do with calculating width, since all the characters in a fixed width font are all the same width. Instead it seems that the first iteration of each said character are not being counted, possibly because they are also accepted for breaking characters.

Note the following weirdness occurring: (U+201C in this example)
image
Note line # 337 repeats twice.

@qaqz111
Copy link
Author

qaqz111 commented May 23, 2019

since all the characters in a fixed width font are all the same width.

I'm sorry but this is not true. You can get the details following these reference links:
http://www.unicode.org/reports/tr11/
https://www.unicode.org/Public/UCD/latest/ucd/EastAsianWidth.txt

That the characters are all the same width in your VSCode is possibly because the font you are using sets the characters mentioned above to half-width, but in fact they should be full-width. And there are many characters that are full-width, for example most of the CJK characters like 好好学习天天向上あいうえお, full-width digits and alphabets like 1234ABCD, and punctuations used in these contexts like ,。:;‘’“”【】()《》『』, etc.

@rebornix rebornix added the editor-wrapping Editor line wrapping issues label Aug 2, 2019
@rebornix rebornix added the feature-request Request for new features or functionality label Oct 21, 2019
@alexdima alexdima assigned alexdima and unassigned rebornix Jan 10, 2020
@alexdima
Copy link
Member

The width of the characters ‘’“” depends on the used font. They are not the same (semantically) as 1234ABCD, which are specified in the Unicode standard as being fullwidth: e.g.

- Unicode Character 'FULLWIDTH DIGIT ONE' (U+FF11)
- Unicode Character 'LEFT SINGLE QUOTATION MARK' (U+2018)

Our current wrapping implementation works OK for fullwidth characters because we measure one as a reference and use the width measured on that one for all fullwidth characters. But we cannot change to be treated as a fullwidth character, because it is not a fullwidth character across all fonts.

Let's therefore track in #2654

@alexdima alexdima added the *duplicate Issue identified as a duplicate of another issue(s) label Jan 10, 2020
@qaqz111
Copy link
Author

qaqz111 commented Jan 14, 2020

@alexdima Yes you are right about the width of characters like U+2018, and that's the point. According to the Unicode® Standard Annex #11 these characters are East Asian Ambiguous, therefore require additional information not contained in the character code to further resolve their width.

But VSCode seems to treat them as simple Narrow characters and give them halfwidth characters' width regardless the font used and therefore the horizontal scrollbar appears in word wrap mode.

Wrap

To reproduce this issue:

  1. Use a chinese or japanese font as first value of Editor: Font Family in preference which give these Ambiguous character wide width(e.g. Simsun in a Simplified Chinese Windows)
  2. Input some text in VSCode editor like ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890
  3. Toggle Word Wrap in VSCode through command or Alt+Z
  4. Copy one or all of these characters ‘’“” and paste to line begin repeatly, and you'll see the horizontal scrollbar appears
  5. Press Alt+Z repeatly and pay attention to the horizontal scrollbar you can see the issue

The point is, these characters ‘’“” in most East Asia context (e.g. chinese) they are always wide width as fullwidth characters, but VSCode can not process them correctly.

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-wrapping Editor line wrapping issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants