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: Different colors for same keyword #1378

Open
LostInCompilation opened this issue Jun 21, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@LostInCompilation
Copy link

LostInCompilation commented Jun 21, 2023

Description

When opening the attached header file, syntax highlighting fails on many occasions of the keyword double. The color switches between bright and dark blue.

Download source file

Pastebin: Show file CPoint.h

To Reproduce

  1. Download and open the attached file

Expected Behavior

Correct syntax highlighting.

Version Information

CodeEdit: 0.0.3-alpha (32)
macOS: 13.4
Xcode: 14.3.1

Additional Context

No response

Screenshots

Screenshot 2023-06-21 at 18 09 34
@LostInCompilation LostInCompilation added the bug Something isn't working label Jun 21, 2023
@thecoolwinter
Copy link
Collaborator

Moving to CETV for further investigation

@thecoolwinter thecoolwinter transferred this issue from CodeEditApp/CodeEdit Jun 24, 2023
@thecoolwinter
Copy link
Collaborator

This is happening due to the fact that CE primarily uses the filename to detect which language the file is. Because this is a .h file, CE decides that it's a C header file rather than a Cpp header file. In the latest CE version you can select what language is being used to parse the file for syntax using the inspector sidebar. The below screenshot was taken using the Cpp parser and you can see it recognizes private and public as keywords of their own.

Screenshot 2023-07-14 at 2 43 46 PM

A fix for this would be to add a way to override filetypes for detection using a setting like this. I'm going to move this to CE again (sorry) because that setting should be implemented there.

@thecoolwinter thecoolwinter transferred this issue from CodeEditApp/CodeEditSourceEditor Jul 14, 2023
@Sophiahooley
Copy link

Hi there. I have been looking into this issue, and would like to work on it. If there has been any update on anything regarding it, please let me know.

Regarding the suggestion for language identifiers like VSCode, do you have any ideas @thecoolwinter on how exactly you want that implemented? I've looked through the code a little and see how it might play into the existing FileType enum and CodeLanguage struct. If there are any more details or ideas that you may have thought about, please let me know as I begin to work this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: 📋 Todo
Development

No branches or pull requests

3 participants