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

Regex on new line breaks js/ts highlighter #1024

Open
moritz-t-w opened this issue Feb 9, 2024 · 6 comments · May be fixed by #1018
Open

Regex on new line breaks js/ts highlighter #1024

moritz-t-w opened this issue Feb 9, 2024 · 6 comments · May be fixed by #1018

Comments

@moritz-t-w
Copy link

moritz-t-w commented Feb 9, 2024

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

  • VS Code Version:
1.85.2
c8a36a69377856369f139f39ee56dd3838130fbf
x64
  • OS Version: n/a

Putting a regular expression on a new line in JavaScript or TypeScript breaks the highlighter.
Steps to Reproduce:

  1. paste this:
1
	/ f(/u/g)
function f(_: RegExp) {
	return 1;
}
  1. make sure the language mode is set to TypeScript
    Expected:
    Same highlighting as this:
    u replaced with e

Actual:
Highlighting is wrong after the first line.

Theme: @id:vscode.theme-defaults: Dark +

@moritz-t-w
Copy link
Author

This happens with a bunch of characters, such as [({})]

@mirusky
Copy link

mirusky commented Feb 9, 2024

Maybe related to microsoft/vscode#204824

@RedCMD
Copy link

RedCMD commented Feb 9, 2024

how is that not a typescript error?
having rogue slashes and/or brackets

@moritz-t-w
Copy link
Author

@RedCMD
It's 1 divided by f(/u/g), the slashes in the function call being regex notation

@moritz-t-w
Copy link
Author

Maybe related to microsoft/vscode#204824

@mirusky
From what I understand, the linked issue was a duplicate of microsoft/vscode#203998, which has been traced back to the go formatter used, not vscode,

@RedCMD
Copy link

RedCMD commented Feb 12, 2024

It's 1 divided by f(/u/g)

my bad

looking at the TextMate code
looks like a simple fix
I'll make a PR soon

change ([dgimsuy]+|(?![\\/\\*])|(?=\\/\\*)) to (?!\\*)[dgimsuy]*((?!\\/)|(?=\\/\\*))

<string>(?&lt;!\+\+|--|})(?&lt;=[=(:,\[?+!]|^return|[^\._$[:alnum:]]return|^case|[^\._$[:alnum:]]case|=&gt;|&amp;&amp;|\|\||\*\/)\s*(\/)(?![\/*])(?=(?:[^\/\\\[\()]|\\.|\[([^\]\\]|\\.)+\]|\(([^\)\\]|\\.)+\))+\/([dgimsuy]+|(?![\/\*])|(?=\/\*))(?!\s*[a-zA-Z0-9_$]))</string>

@RedCMD RedCMD linked a pull request Feb 13, 2024 that will close this issue
@mjbvz mjbvz transferred this issue from microsoft/vscode Mar 21, 2024
@mjbvz mjbvz removed their assignment Mar 21, 2024
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 a pull request may close this issue.

4 participants