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

Main text considered as string by VS Code? [Single " is causing issues] #603

Closed
junyuan-chen opened this issue May 6, 2018 · 11 comments
Closed

Comments

@junyuan-chen
Copy link

junyuan-chen commented May 6, 2018

After updating to version 5.3.2., the main text in a tex file is considered as string by VS Code. As a consequence, the color for the syntax highlighting is changed (as well as the rule for word-based suggestions).

Is that an intentional change to treat the text as string?

Update:
screen shot 2018-05-05 at 10 53 34 pm
screen shot 2018-05-05 at 10 52 26 pm

I know that VS Code treat these text as string because after I change the setting for string in editor.tokenColorCustomizations, the color of the text is changed.

Update2:
It turns out that the problem is caused by a piece of macro in the preamble:

	\begingroup\lccode`\~=`\|
	\lowercase{\endgroup\let~}\innermid 
	\mathcode`|=\string"8000
       }

After removing " near the end of that piece of macro, the main text will be correctly recognized as before (rather than string).

@James-Yu
Copy link
Owner

James-Yu commented May 6, 2018

Can you please give an example on how it changed? I am personally using the One Dark Pro color theme and I did not notice any issues/changes w.r.t 5.3.2.

@junyuan-chen
Copy link
Author

@James-Yu Thanks for reply!

Actually, I happen to use One Dark Pro as well. I would be surprised if this is only special to my case, as I didn't change anything else except that I updated both the LaTeX workshop extension and VS Code to the latest version.

@James-Yu
Copy link
Owner

James-Yu commented May 6, 2018

I suppose so. Do you mind posting a screenshot on the text which you think the highlighter was doing wrong?

@junyuan-chen
Copy link
Author

@James-Yu I just edited the main post above.
My temporary remedy for this issue is to change the color for string in editor.tokenColorCustomizations.
I know that VS Code treat these text as string because after I change the setting for string in editor.tokenColorCustomizations, the color of the text is changed, though these pieces of text are not supposed to be string.

@James-Yu
Copy link
Owner

James-Yu commented May 6, 2018

Very strange, below is a patch of my current work:
image
You can see nothing is changed, and my editor.tokenColorCustomizations is {}. I'd advice you to post your tex file for debug purpose.

@James-Yu
Copy link
Owner

James-Yu commented May 6, 2018

@jlelong do you mind have a brief check on this issue? I'm scratching my head to understand the plists 😭

@junyuan-chen
Copy link
Author

junyuan-chen commented May 6, 2018

@James-Yu

After some trial and error, I have just found where the issue comes from!

I have the following macro in the preamble:

	\begingroup\lccode`\~=`\|
	\lowercase{\endgroup\let~}\innermid 
	\mathcode`|=\string"8000
       }

The above piece of macro is obtained from: https://tex.stackexchange.com/questions/187162/vertical-bar-for-absolute-value-and-conditional-expectation

After deleting the "8000 part, everything becomes normal. But, this piece of macro did not cause any problem in the previous versions.

@James-Yu
Copy link
Owner

James-Yu commented May 6, 2018

Hmm, I'll do some debug on this.

@junyuan-chen junyuan-chen changed the title Main text considered as string by VS Code? Main text considered as string by VS Code? [Single " is causing issues] May 6, 2018
@James-Yu
Copy link
Owner

James-Yu commented May 6, 2018

It seems that 122b706 is the problem. I'm working on a solution.

@jlelong
Copy link
Collaborator

jlelong commented May 6, 2018

This is related to #593. I plan to make a PR on all this by the end of the day.

@James-Yu
Copy link
Owner

James-Yu commented May 6, 2018

@jlelong Please kindly note that I just pushed a dirty hack which removes " to " pairing highlight in the commit above. I've no idea if that may break something or not, yet I suppose not 🤣

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants