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 doesn't work well with control characters #112382

Closed
JayXon opened this issue Dec 13, 2020 · 13 comments
Closed

Word wrap doesn't work well with control characters #112382

JayXon opened this issue Dec 13, 2020 · 13 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-wrapping Editor line wrapping issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@JayXon
Copy link

JayXon commented Dec 13, 2020

  • VSCode Version: 1.52.0
  • OS Version: windows 10

Steps to Reproduce:

  1. enable word wrap
"editor.wordWrap": "on"
  1. type a long line with control characters in it, for example

  2. observe that horizontal scroll bar shows up

image

Does this issue occur when all extensions are disabled?: Yes

@vscodebot
Copy link

vscodebot bot commented Dec 13, 2020

@alexdima
Copy link
Member

The default word wrapping algorithm assumes (mostly) that all characters have the same width. You can change that (at the cost of performance) with "editor.wrappingStrategy": "advanced", which will give more accurate wrapping results, but will be slower, especially for large files.

@alexdima alexdima added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Dec 14, 2020
@JayXon
Copy link
Author

JayXon commented Dec 14, 2020

Thanks for the reply, I wasn't aware of that setting, after changing it to advanced, it did help in some cases, however, I'm still seeing horizontal scroll bar if the entire line is control characters.

@alexdima alexdima reopened this Dec 14, 2020
@alexdima
Copy link
Member

@JayXon Here I have tried with the following settings:

    "editor.wordWrap": "on",
    "editor.wrappingStrategy": "advanced",
    "editor.renderControlCharacters": true

But this is the rendering I get:
image

Do you perhaps use a custom font family that would render that specific control character better?

@alexdima alexdima added info-needed Issue requires more information from poster and removed *question Issue represents a question, should be posted to StackOverflow (VS Code) labels Dec 14, 2020
@JayXon
Copy link
Author

JayXon commented Dec 14, 2020

Looks like github automatically replaced the character with the replacement character, when I copy it back it also shows up like that. This character is \x06, you can get it yourself by opening browser console and put '\x06', and copy from the output.
image

For the font I was using DroidSansMono, but I tried changing back to the default consolas and can still reproduce.

@JayXon
Copy link
Author

JayXon commented Dec 14, 2020

If I turn off renderControlCharacters and set wrappingStrategy to advanced, then I can no longer reproduce.

    "editor.wrappingStrategy": "advanced",
    "editor.renderControlCharacters": false

But can reproduce if renderControlCharacters is true, or wrappingStrategy is simple, or both.

@alexdima
Copy link
Member

Thank you, I could reproduce. The substitution characters for control characters are often wide, so I will adjust the char width computation to assume that these characters are wide.

@alexdima alexdima added editor-wrapping Editor line wrapping issues bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Dec 18, 2020
@alexdima alexdima added this to the January 2021 milestone Dec 18, 2020
@rzhao271 rzhao271 added the author-verification-requested Issues potentially verifiable by issue author label Jan 26, 2021
@github-actions
Copy link

This bug has been fixed in to the latest release of VS Code Insiders!

@JayXon, you can help us out by confirming things are working as expected in the latest Insiders release. If things look good, please leave a comment with the text /verified to let us know. If not, please ensure you're on version 1a9dd75 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

@rzhao271
Copy link
Contributor

Rendering control characters and using the advanced wrapping strategy results in a scrollbar.
Not rendering control characters and using the simple wrapping strategy results in the text wrapping too early.

@rzhao271 rzhao271 added verification-found Issue verification failed and removed author-verification-requested Issues potentially verifiable by issue author labels Jan 28, 2021
@aeschli
Copy link
Contributor

aeschli commented Jan 29, 2021

@rzhao271 Should the issue be reopened then?

@alexdima
Copy link
Member

alexdima commented Jan 29, 2021

@rzhao271 This works for me. When using advanced I don't see a scrollbar:

{
    "editor.wordWrap": "on",
    "editor.wrappingStrategy": "advanced",
    "editor.renderControlCharacters": true
// ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
}

image

@rzhao271
Copy link
Contributor

I think there's a settings sync bug, but one can still see the ACKs don't wrap whereas the substitution character does.

ACKs:
bad-ack

Substitution characters:
good-control

@alexdima alexdima modified the milestones: January 2021, February 2021 Feb 1, 2021
@alexdima alexdima removed the verification-found Issue verification failed label Feb 1, 2021
@alexdima
Copy link
Member

alexdima commented Feb 1, 2021

@rzhao271 Thank you, I could reproduce with ACK and "editor.wrappingStrategy": "advanced"

@rzhao271 rzhao271 added the verified Verification succeeded label Feb 24, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-wrapping Editor line wrapping issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants
@JayXon @alexdima @aeschli @rzhao271 and others