ajaxorg / ace

Ace (Ajax.org Cloud9 Editor)
https://ace.c9.io
Other
26.72k stars 5.28k forks source link

C++ highlighting bug? #1170

Closed niXman closed 11 years ago

niXman commented 11 years ago

In the attached screenshot is shown the highlighting for three lines with the use of the directive '#include' in C++ mode. I have two questions:

  1. Why the first two lines are highlighting differently? Why in the first case the angle brackets are not highlighted and in the second - are highlighted?
  2. Why the file name in angle brackets is not highlighted in the same color as the brackets themselves?

Thanks.

1

nightwing commented 11 years ago

first one is because this rule, second just highlights >, < operators, and last one is just a regular string. I don't know c++ syntax good enough, how should they be highlighted?

niXman commented 11 years ago

The file name specified after the '#include', regardless of in what symbols it is enclosed, must be displayed in the same color as the '#include' directive itself. The file name can be enclosed only in double quotes or angle brackets. Ideally, the preprocessor directive continues until a line break ( \n ). If the string with a preprocessor directive ends with a backslash( \ ), the next line after it is considered its continuation - as if it was a hole line. This is true for all preprocessor directives, i.e. for lines that begin with the '#' symbol.

The next four examples have the same result:

#include <iostream>

#include \
   <iostream>

#include \
   \
   <iostream>

#include \
   \
   "iostream"

Thank you!

gjtorikian commented 11 years ago

I like having different colors for the directive #include versus the content being included.

However, I believe this is a Theme issue as well, not just a syntax highlighting issue. Check out the same code using Twilight instead of Monokai:

Screen Shot 2012-12-24 at 11 57 23 AM

The first include is properly colored; the second is not; and the third matches the string coloring. I will make it so that they all match the first < > style ( i.e. the third one should not be interpreted as a string).

niXman commented 11 years ago

That would be great!

Tell me please, can you do something so that the multiline preprocessor directives are highlighted correctly?

niXman commented 11 years ago

I don't know, should I continue writing here about multiline preprocessor directives highlighting bug? Now, this bug occurs when in multiline preprocessor directive double quoting char( \" ) are contained.

Thanks.

untitled

himanshu010 commented 3 years ago

what is the code for c++ language, I tried "c++", "cpp" but both of them doesn't work.