Vscode: Render non-breaking space when renderWhitespace is active

Created on 5 Oct 2016  路  5Comments  路  Source: microsoft/vscode

I ran into an usability problem with a specific keyboard layout (b茅po, a French dvorak variant) and VSCode. The shift+space combination produces non-breaking spaces (U+00A0), and it is very easy to hit involuntarily when typing a space before or after a capital letter. This is not a problem itself, but it becomes one when a codebase is littered with invisible non-ASCII characters.

A simple fix in my case would be to show non-breaking spaces in an obvious way when editor.renderWhitespace is turned on. In 1.5.3 non-breaking space seems to be treated like a word character by renderWhitespace.

Emacs displays it even out of whitespace-mode with a bold colored underscore, and that can be done in Vim with listchars. As this does not look like a very complicated problem, I could submit it as a first PR to the project.

I checked, but if this has already been fixed or the discussion has already taken place, please feel free to close the issue.

P.S.聽: VSCode is an awesome piece of software and a pleasure to use, please keep up with the great work!

  • VSCode Version: 1.5.3
  • OS Version: Linux 4.7.6-1-ARCH x86_64 GNU/Linux

Steps to reproduce:

  1. Turn on renderWhitespace
  2. Insert a non-breaking space (U+00A0) in the middle of an indentation
  3. The non-breaking space character is invisible, and the indentation following it becomes invisible
editor-render-whitespace feature-request

Most helpful comment

I feel this would be useful even without renderWhitespace on: I suspect the majority of cases in which it appears in code, it's a mistake.
If anyone's interested in fixing it, I think it should be straightforward:

  1. Remove the check here to call the whitespace rendering function always (though you'll need to make sure to be careful only to render the correct whitespace):
    https://github.com/Microsoft/vscode/blob/c15001e11d8a9a4a96f94deaceb70c3bc4259013/src/vs/editor/common/viewLayout/viewLineRenderer.ts#L319-L321
  2. Add checks for other whitespace characters other than space and tab:
    https://github.com/Microsoft/vscode/blob/c15001e11d8a9a4a96f94deaceb70c3bc4259013/src/vs/editor/common/viewLayout/viewLineRenderer.ts#L465-L487

All 5 comments

With the release of 1.6 and the new renderWhitespace settings, inserting a non-breaking space does not make the indentation after it invisible anymore, but the non-breaking space character itself is still invisible.

I have a similar issue as well, making non breaking space with alt+space (Slovenian Apple keyboard). Unfortunately it breaks almost every second class (SASS) I make, because I press alt too early.

Bump

I feel this would be useful even without renderWhitespace on: I suspect the majority of cases in which it appears in code, it's a mistake.
If anyone's interested in fixing it, I think it should be straightforward:

  1. Remove the check here to call the whitespace rendering function always (though you'll need to make sure to be careful only to render the correct whitespace):
    https://github.com/Microsoft/vscode/blob/c15001e11d8a9a4a96f94deaceb70c3bc4259013/src/vs/editor/common/viewLayout/viewLineRenderer.ts#L319-L321
  2. Add checks for other whitespace characters other than space and tab:
    https://github.com/Microsoft/vscode/blob/c15001e11d8a9a4a96f94deaceb70c3bc4259013/src/vs/editor/common/viewLayout/viewLineRenderer.ts#L465-L487

Also met similar problem when comparing two list of strings. the &#8203 --> Unicode Character 'ZERO WIDTH SPACE'(U+200B) is annoying.

List of more invisible characters & General Punctuation for your reference

| Symbol|Entity|HTML-code|Unicode|Name|
|---------|--------|-----------|---------|-------|
|聽| | |U+00A0|No-Break Space|
|颅|­|­|U+00AD|Soft Hyphen|
|鈥倈 | |U+2002|En Space|
|鈥億 | |U+2003|Em Space|
|鈥墊 | |U+2009|Thin Space|
|鈥墊 | |U+200A|Hair Space|
|鈥媩​|​|U+200B|Zero Width Space|
|鈥寍‌|‌|U+200C|Zero Width Non-Joiner|
|鈥峾‍|‍|U+200D|Zero Width Joiner|
|鈥巪‎|‎|U+200E|Left-To-Right Mark|
|鈥弢‏|‏|U+200F|Right-To-Left Mark|

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ozsay picture ozsay  路  247Comments

Brakkar picture Brakkar  路  364Comments

TurkeyMan picture TurkeyMan  路  411Comments

misolori picture misolori  路  282Comments

stoffeastrom picture stoffeastrom  路  380Comments