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++ syntax highlighting broken by line break before array square bracket #85385

Closed
valentjn opened this issue Nov 22, 2019 · 7 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug grammar Syntax highlighting grammar
Milestone

Comments

@valentjn
Copy link

valentjn commented Nov 22, 2019

  • VSCode Version: 1.41.0-insider (599c076, 2019-11-22T07:25:24.031Z)
  • OS Version: Windows_NT x64 10.0.17763

Steps to Reproduce:

  1. Open a new file.
  2. Change the language mode to C++.
  3. Insert the following code:
#include <iostream>

int array
[42];

// this is a comment
int variable1;
int variable2;

int main() {
  std::cout << "Hello World!\n";
  return 0;
}
  1. Observe that the syntax highlighting between // this is a comment and int main() { (both inclusive) is broken (i.e., the text is white).
  2. Remove the line break between int array and [42];.
  3. Observe that the syntax highlighting is normal again.

This is especially important for deeply nested arrays, when the declaration of the array becomes too long to put it on one line.

In addition, array is blue if there is no whitespace (line break or space characters) before the opening square bracket, and array is white if there is whitespace. Is this another issue?

Due to firewall restrictions I can't upload screenshots right now, sorry.

This might be related to #76225 (comment) and jeff-hykin/better-cpp-syntax#279.

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

matter123 added a commit to jeff-hykin/better-cpp-syntax that referenced this issue Nov 22, 2019
@alexr00 alexr00 added bug Issue identified by VS Code Team member as probable bug grammar Syntax highlighting grammar labels Nov 25, 2019
@alexr00 alexr00 added this to the November 2019 milestone Nov 25, 2019
@alexr00
Copy link
Member

alexr00 commented Nov 25, 2019

Looks like the the folks over at https://github.com/jeff-hykin/cpp-textmate-grammar are on top of this (as usual!). Once they've merged in their fix from jeff-hykin/better-cpp-syntax#423 I'll pull in the changes.

@valentjn
Copy link
Author

valentjn commented Nov 25, 2019

@alexr00 @matter123 Great, but I think jeff-hykin/better-cpp-syntax#423 is not sufficient to fix this as it only seems to be about digits after the [ (at least according to the PR title). However, this issue is independent of having a digit there, e.g.

#define ARRAY_SIZE 10

int array
[ARRAY_SIZE];

// This is a comment that won't be formatted correctly.

has the same problem.

Edit: The PR jeff-hykin/better-cpp-syntax#423 has been amended to fix this as well 👍

Edit: jeff-hykin/better-cpp-syntax#423 has been closed in favor of jeff-hykin/better-cpp-syntax#437.

@alexr00 alexr00 modified the milestones: November 2019, December 2019 Dec 2, 2019
@valentjn
Copy link
Author

@alexr00 jeff-hykin/better-cpp-syntax#437 has been merged to master (it's not yet in the released extension). I can confirm this fixes the formatting issue 😄

@alexr00
Copy link
Member

alexr00 commented Jan 23, 2020

Excellent. I will pull in the change in a week or so.

@valentjn
Copy link
Author

Any updates? Still open in 1.44.0.

@alexr00
Copy link
Member

alexr00 commented Apr 14, 2020

There is a different bug that is preventing us from getting the most recent grammar changes jeff-hykin/better-cpp-syntax#460

@alexr00
Copy link
Member

alexr00 commented Nov 5, 2020

We have now pulled in all the recent cpp grammar changes.

@alexr00 alexr00 closed this as completed Nov 5, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 21, 2020
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 grammar Syntax highlighting grammar
Projects
None yet
Development

No branches or pull requests

2 participants