microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.42k stars 29.33k forks source link

Column selection with CJK character #9989

Closed ziofat closed 6 years ago

ziofat commented 8 years ago

Steps to Reproduce:

  1. Copy and paste the following Chinese, Japanese and English sentences to VS code.
人人生而自由,在尊严和权利上一律平等。
すべての人間は、生まれながらにして自由であり、かつ、尊厳と権利と について平等である。
All human beings are born free and equal in dignity and rights.

The sentences above are official translation of UDHR.

  1. Use Shift + Alt + Click to select columns.

The behavior is: vscode

CJK characters are usually have double width than other characters. So visually the column of CJK characters and English characters are not same. When I use column selection to select CJK/English mixed codes this issue will affect the result.

The expected behavior is like what Sublime Text does: sublime

Tyriar commented 8 years ago

I notice the CJK characters are also not aligned correctly. They should exactly as wide as 2 normal characters.

ziofat commented 8 years ago

@Tyriar Actually they are. The Japanese line seems not aligned correctly is because the symbol has weird width in VSCode. I checked and found this was my font settings issue and corrected it as Sublime Text. When using Yahei font, the should be full width as general CJK characters.

And this is what it looks like:

image

alexdima commented 8 years ago

The column selection is implemented with logical columns (not "screen columns") -- we definitely have similar issues for RTL text, for Bi-Di and for non-monospace fonts.

Implementing column selection with "screen columns" is IMHO difficult.

ziofat commented 8 years ago

I think you don't need to think it as screen column, just make column selection smarter. VSCode already treats the tab as 4-width length charcter (which can be set in preference), and CJK will be 2-width length in monospace font (it is not necessary to be available in preference because all monospace CJK font have same size.). User can choose their font to suit the editor but not languages.

alexdima commented 6 years ago

Duplicate of #22717