CodeEdit icon indicating copy to clipboard operation
CodeEdit copied to clipboard

🐞 C++ Syntax highlighting: Different colors for same keyword

Open LostInCompilation opened this issue 2 years ago • 3 comments

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 avatar Jun 21 '23 16:06 LostInCompilation

Moving to CETV for further investigation

thecoolwinter avatar Jun 24 '23 05:06 thecoolwinter

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 avatar Jul 14 '23 19:07 thecoolwinter

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.

Sophiahooley avatar Apr 01 '24 17:04 Sophiahooley