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

Escape characters are highlighted in character arrays #75

Open
goldrik opened this issue Jan 5, 2024 · 3 comments
Open

Escape characters are highlighted in character arrays #75

goldrik opened this issue Jan 5, 2024 · 3 comments
Labels

Comments

@goldrik
Copy link

goldrik commented Jan 5, 2024

Describe the bug
When initializing a raw string variable, escape characters (backslash + char) get highlighted by default. This occurs for character arrays (using single quotes), but not for strings (using double quotes).

For example, when defining a Windows path:
temp_path = '\\somedrive\path\to\right\folder\';
In this case, the escape characters \\, \r, \t, and \f characters would be highlighted.

If you do the same but with double quotations, the error does not occur. This is the expected behavior.

@goldrik goldrik added the bug label Jan 5, 2024
@goldrik goldrik changed the title Prevent highlighting of escape characters in character arrays Escape characters are highlighted in character arrays Jan 5, 2024
@dklilley
Copy link
Member

dklilley commented Jan 5, 2024

Hi @goldrik , thanks for reporting this!

For clarity, can you please attach an image showing this behavior?

@goldrik
Copy link
Author

goldrik commented Jan 5, 2024

Yup, here's the same string, initialized as a character array, then as a string.

Screenshot 2024-01-05 at 1 52 34 PM 2

@dklilley
Copy link
Member

dklilley commented Jan 8, 2024

I don't think it is a bug that the escape characters are being highlighted in character vectors - they are explicitly being tokenized as constant.character.escape.matlab. It is definitely incorrect, however, that they are being treated differently between char vectors and string arrays.

I am moving this issue over to the MATLAB-Language-grammar repository, because this is an issue with the grammar.

@dklilley dklilley transferred this issue from mathworks/MATLAB-extension-for-vscode Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants