Skip to content

Allow \n to trigger a softwrap #231120

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

rfon6ngy
Copy link

@rfon6ngy rfon6ngy commented Oct 11, 2024

ref: #231118 (2024) + #89120 (2020)

Goal

This PR add soft-wrapping on literal \n in addition to viewport and column based limitation when editor.wrapOnEscapedLineFeeds is enabled.

So this JSON declaration
image
would be shown as
image

previous failed attempts: There are currently no extension There are currently no extension API that would allow a language-specific extension to hint the editor into soft-wrapping at specific offset. So I create a test extension that would inject `
` and `\n` in the editor view (using `InlayHints` and `createTextEditorDecorationType`) but none of them worked and were rendered inline

Image

So the only way was to add the wrapping detection in the createLineBreaks method of the MonospaceLineBreaksComputerFactory

@rfon6ngy
Copy link
Author

rfon6ngy commented Oct 11, 2024

I'm open to discussions about:

  • hide this behavior behind a possible wordWrapOnLiteral boolean EditorOption
  • Providing a wrapping API for VSCode extension instead (would allow a language-specific decision) =>this is way above my skills

Copy link

@GhislainC GhislainC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Copy link

@paul-ay paul-ay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok for me

Copy link

@Amaury2T Amaury2T left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing to me !

Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea! Could you please implement this behind a setting, maybe something like editor.wrapOnEscapedLineFeeds or maybe you have a better idea for a name.

@rfon6ngy
Copy link
Author

rfon6ngy commented Nov 1, 2024

Hi @alexdima sorry for the delay. I'm on holiday today so yeah I've hidden the feature behind a editor.wrapOnEscapedLineFeeds flag.

See for yourself: default config

image

with editor.wrapOnEscapedLineFeeds set to true

image

@rfon6ngy rfon6ngy force-pushed the patch-1 branch 2 times, most recently from dfa2613 to 65fe597 Compare November 1, 2024 12:23
@rfon6ngy
Copy link
Author

rfon6ngy commented Nov 1, 2024

@microsoft-github-policy-service agree

@rfon6ngy
Copy link
Author

@alexdima do you need anything else ?

@rfon6ngy rfon6ngy requested a review from alexdima December 2, 2024 13:49
@rfon6ngy

This comment was marked as spam.

@rfon6ngy
Copy link
Author

rfon6ngy commented Dec 21, 2024

Seems like I'm not the first one with this idea...
Ref #89120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants