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++: Add enum class to class names #2342

Merged
merged 5 commits into from Apr 29, 2020
Merged

C++: Add enum class to class names #2342

merged 5 commits into from Apr 29, 2020

Conversation

jsmolka
Copy link
Contributor

@jsmolka jsmolka commented Apr 29, 2020

Prism falsy indentifies the class in enum class as a class name and therefore applies the wrong color.

image

This commit fixes it. The order, before enum itself, is important.

image

Co-Authored-By: Michael Schmidt <mitchi5000.ms@googlemail.com>
@RunDevelopment
Copy link
Member

Thank you for this fix @jsmolka!

To make the build pass, you also have to commit the minified files. Install Prism's dependencies using npm ci, run npx gulp, and commit all changes. The build should now pass.

Please also add the previous error to this test.

@jsmolka
Copy link
Contributor Author

jsmolka commented Apr 29, 2020

@RunDevelopment I have already tried altering the test file in the following way

class Foo
class Foo_bar
struct foo
enum bar
enum class FooBar

----------------------------------------------------

[
	["keyword", "class"], ["class-name", "Foo"],
	["keyword", "class"], ["class-name", "Foo_bar"],
	["keyword", "struct"], ["class-name", "foo"],
	["keyword", "enum"], ["class-name", "bar"],
	["keyword", "enum class"], ["class-name", "FooBar"]
]

----------------------------------------------------

Checks for class names.

After running gulp and then npm run test I got

: expected [ Array(11) ] to deeply equal [ Array(10) ]
      + expected - actual

           "bar"
         ]
         [
           "keyword"
      -    "enum"
      +    "enum class"
         ]
         [
      -    "keyword"
      -    "class"
      -  ]
      -  [
           "class-name"
           "FooBar"
         ]
       ]

@RunDevelopment
Copy link
Member

Yes, the test suite because the expected JSON wasn't updated. Use npm run test:languages -- --pretty to get correct formatted JSON.

@jsmolka
Copy link
Contributor Author

jsmolka commented Apr 29, 2020

The test still fails :/

@RunDevelopment
Copy link
Member

The correct JSON is probably this:

[
	["keyword", "class"], ["class-name", "Foo"],
	["keyword", "class"], ["class-name", "Foo_bar"],
	["keyword", "struct"], ["class-name", "foo"],
	["keyword", "enum"], ["class-name", "bar"],
	["keyword", "enum"], ["keyword", "class"], ["class-name", "FooBar"]
]

@jsmolka
Copy link
Contributor Author

jsmolka commented Apr 29, 2020

That fixed it, thanks!

@RunDevelopment RunDevelopment merged commit 30b4e25 into PrismJS:master Apr 29, 2020
@RunDevelopment
Copy link
Member

Thank you for contributing @jsmolka!

quentinvernot pushed a commit to TankerHQ/prismjs that referenced this pull request Sep 11, 2020
The `class` keyword in `enum class` enums was falsely highlighted as the class name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants