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

single-line comments break highlighting on the next line #79

Open
AdamRaichu opened this issue Jan 9, 2024 · 2 comments
Open

single-line comments break highlighting on the next line #79

AdamRaichu opened this issue Jan 9, 2024 · 2 comments

Comments

@AdamRaichu
Copy link

On GitHub.com, C++ code is incorrectly highlighted after a line that contains a // comment.

Example code demonstrating the problem:

const byte hello = 1;  // This is a comment
const byte world = 2;  // `const` should be highlighted, but it is not

const byte foo = 3; /* This problem does not occur with multiline comments. */
/* Multiple
lines */
const byte bar = 4;

// This comment breaks highlighting as well.
const byte a = 5;
const byte b = 6;

// This also breaks highlighting in other ways
int main() {}

int test() {}

// Even this breaks
x_y();

y_z();

// Another example
a_z(); a_z();

Reporting here because of instructions in this repo.

@sethrj
Copy link

sethrj commented Feb 20, 2024

It took me literally half an hour of digging through source code, github support, and google, to find this.

As of some recent update, Github syntax highlighting for C++ is terribly broken by this error, especially if you have multi-line comments following a single-line comment as our codebase does:

namespace celeritas
{
//---------------------------------------------------------------------------//
/*!
 * Calculate the transport cross section for the Wentzel OK and VI model.
 *
 * \note This performs the same calculation as Geant4's
 * G4WentzelOKandVIxSection::ComputeTransportCrossSectionPerAtom.
 */
class WentzelTransportXsCalculator
{
  public:
    //!@{
    //! \name Type aliases
    using XsUnits = units::Native;  // [len^2]
    using Charge = units::ElementaryCharge;
    using Mass = units::MevMass;
    using MomentumSq = units::MevMomentumSq;
    //!@}
   /* and so forth */
};

The first single-line comment causes the /*! block highlight to be ignored, which then causes the apostrophe inside the comment to be interpreted as a character string...

(this renders for me, as of Feb 2024, as
Screenshot 2024-02-20 at 15 14 51
)

@sethrj
Copy link

sethrj commented Feb 20, 2024

I don't think this is a bug in this repository because the issue only recently started manifesting on GitHub, and the last commit for this repository was years ago.

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

No branches or pull requests

2 participants