Problems caused by vscode control characters and Solutions

Time:2019-12-31

1. environment

  • macOS Sierra 10.12.5
  • Vscode 1.20.0 latest

2. How to reproduce this problem

When using the Chinese input method to input Chinese, always press the back key, for example, inputsfsf, when you press the back key four times, you will find that although the pop-up box of Sogou input method disappears, there is still one left on the pagesThat’s how you click back again,sWill becomebs, becomes a hidden character. This usually appears when there is a markdown rendering plug-in on the right.

From a more precise point of view, once your editor opens WebView, it will cause this problem. Even the welcome page of vscode is also WebView, which will also cause this problem. So it’s best to close WebView as much as possible when writing code.

Problems caused by vscode control characters and Solutions

3. How to make hidden characters appear

The Mac version of vscode control characters are generally not displayed, you can use the following methods to display them

"editor.renderControlCharacters": true

In the editor, it looks like a very smallBS, which means backspace. Generally, this character appears occasionally when you press back or delete during input.

Problems caused by vscode control characters and Solutions

4. What is the problem with hidden control characters?

4.1. The control character will appear question mark on GitHub

For example, a hidden character appears between and the same character in the figure below, and a question mark with background appears on GitHub.

Problems caused by vscode control characters and Solutions

4.2. When the control character is in hexo next local search, the search.xml rendering will fail, and the search box will rotate all the time

If you use a browser to open search.xml, you will find parsing errors

Problems caused by vscode control characters and Solutions

5. How to solve

5.1. Delete hidden characters manually

You can use substitution, copy a hidden character first, and then replace the hidden character with null

5.2. Use plug-in remove backspace control character

Remove backspace control character

Problems caused by vscode control characters and Solutions

Chrome has been merged at home, so vscode 1.15, released in early August, will be redefined (vscode 1.15, electronic 1.7.4).In fact, up to now, the problem has not been solved

Characteristic

Formatter to remove control characters contained in an open document. The default control characters to be deleted are as follows.

/[\u0000]|[\u0001]|[\u0002]|[\u0003]|[\u0004]|[\u0005]|[\u0006]|[\u0007]|[\u0008]|[\u000b]|[\u000c]|[\u000d]|[\u000e]|[\u000f]|[\u0010]|[\u0011]|[\u0012]|[\u0013]|[\u0014]|[\u0015]|[\u0016]|[\u0017]|[\u0018]|[\u0019]|[\u001a]|[\u001b]|[\u001c]|[\u001d]|[\u001e]|[\u001f]|[\u001c]|[\u007f]/gm

usage

  • “Editor. Formatonsave”: true if set, start when saving
  • “Editor. Formatontype”: true when transformation is performed when it is set; when input is started

5.3. Wait for the official to give a better solution

The official bug is stillopenStatus. Using IME with markdown preview enabled, press ESC/BACKSPACE leads in control characters #37114

5.4. Close all webviews

This problem usually occurs when the tab contains WebView, so after upgrading to the latest version of vscode, when writing code, you should be careful not to open any tab with WebView, including

  • Turn off the real-time rendering function of markdown rendering plug-in
  • Close the vscode welcome tab

6. Why doesn’t the government solve the problem directly?

  • The bottom layer of vscode uses electron, which iselectronThe backspace can not erase the last one character during Japanese ime conversion (MacOS). If the problem is not solved by electronic, vscode will not solve it.
  • Chrome is used in the bottom layer of electron, which ischromiumTwo backspaces required to delete last character in WebView inputbug. If chromium does not solve the problem, elctron cannot solve it.
  • To sum up, up to the time of writing, this problem is still unsolved.

7. reference

  • Is markdown always hidden when writing vscode on Mac?
  • The local search function of hexo next topic is invalid. Clicking the search link cannot pop up the overlay layer
  • Backspace can not erase the last one character during Chinese/Japanese IME conversion (macOS) #24981
  • Backspace can not erase the last one character during Japanese IME conversion (macOS) #9173
  • Two backspaces required to delete last character in webview input
  • Control character
  • Using IME with markdown preview enabled, press ESC/BACKSPACE leads in control characters #37114

Recommended Today

The road of high salary, a more complete summary of MySQL high performance optimization in history

preface MySQL for many linux practitioners, is a very difficult problem, most of the cases are because of the database problems and processing ideas are not clear. Before the optimization of MySQL, we must understand the query process of MySQL. In fact, a lot of query optimization work is to follow some principles so that […]