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

[c++] C & C++ Syntax Highlighting Issues #4769

Closed
SE2Dev opened this issue Mar 29, 2016 · 2 comments
Closed

[c++] C & C++ Syntax Highlighting Issues #4769

SE2Dev opened this issue Mar 29, 2016 · 2 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug candidate Issue identified as probable candidate for fixing in the next release languages-basic Basic language support issues verified Verification succeeded

Comments

@SE2Dev
Copy link

SE2Dev commented Mar 29, 2016

  • VSCode Version: 0.10.11
  • OS Version: Windows 7

Issue 1:

In the following code (using C++ syntax highlighting), the string literal(s) are not highlighted at all.
This issue is exclusive to C++ syntax highlighting and does not occur with C syntax highlighting.

Code:

int main()
{
    printf("%s\n", "a string");
}

Result

Bug Screenshot

Issue 2:

In custom tmLanguage based colorizers that reference source.c from within rules that begin with certain patterns, the inlined C highlighting is incorrect (this issue also applies to rules using source.c++ but does not occur in rules using source.js).

Code

(See https://github.com/SE2Dev/VSCode-BugExample)

Result

Bug Screenshot

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug languages-basic Basic language support issues labels Mar 30, 2016
@aeschli aeschli changed the title C & C++ Syntax Highlighting Issues [c++] C & C++ Syntax Highlighting Issues Mar 31, 2016
@aeschli
Copy link
Contributor

aeschli commented Mar 31, 2016

Hi @SE2Dev, thanks a lot for your great example project. It was very helpful understanding the issue.
I delivered a fix for the first issue.

The second one, however, is a known problem of the c grammar
The C grammar uses $base instead of $self to refer its own rules, as done in a block.
$base is the parent grammar, in your case the exampleLang grammar. So that's why you had to use start again inside a block
The c grammar does that as they assume that the parent grammar is a grammar like C++, that includes C to extend it.

http://textmate.1073791.n5.nabble.com/C-based-grammars-broken-for-embedding-restricting-base-reference-td25165.html
discusses this and recommends to use injection.

@aeschli aeschli closed this as completed Mar 31, 2016
@SE2Dev
Copy link
Author

SE2Dev commented Mar 31, 2016

Thank you very much. I thought the second problem might have had something to do with $base, but wasn't able to find any definitive information on it, the link you provided should definitely help.

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 candidate Issue identified as probable candidate for fixing in the next release languages-basic Basic language support issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants