Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1413 Preprocessor block highlight doesn't ignore trailing comment

Bug
closed-fixed
Neil Hodgson
Scintilla (790)
5
2013-01-17
2012-10-21
Isiledhel
No

In something like
#if CONDITION // my_comment
...
#endif

the content of my_comment impacts the block hightlight.
Example 1:
#if 1 // ===
=> code is grayed out
#endif
#if 1 // ==
=> code is not grayed out
#endif

Example 2: this one brings a 100% crash on my Mac OS X version of SciTE (haven't tested on other platforms)
#if 1 // à
// whatever
#endif

Application Specific Information:
objc[17613]: garbage collection is OFF
Assertion failed: (val >= 0), function Contains, file /Users/nyamatongwe/ttt/merc/nownow/scintilla/cocoa/ScintillaFramework/../../lexlib/CharacterSet.h, line 83.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff88a35ce2 __pthread_kill + 10
1 libsystem_c.dylib 0x00007fff8746b7d2 pthread_kill + 95
2 libsystem_c.dylib 0x00007fff8745ca7a abort + 143
3 libsystem_c.dylib 0x00007fff8748f5de __assert_rtn + 146
4 com.sun.Scintilla 0x00000001000f4d1d Scintilla::CharacterSet::Contains(int) const + 65
5 com.sun.Scintilla 0x00000001001039c0 LexerCPP::EvaluateExpression(std::string const&, std::map<std::string, std::string, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > > const&) + 146
6 com.sun.Scintilla 0x0000000100102f25 LexerCPP::Lex(unsigned int, int, int, Scintilla::IDocument*) + 7149
7 com.sun.Scintilla 0x0000000100155714 Scintilla::LexInterface::Colourise(int, int) + 228
8 com.sun.Scintilla 0x00000001001605b3 Scintilla::Editor::StyleToPositionInView(int) + 83
9 com.sun.Scintilla 0x0000000100167682 Scintilla::Editor::Paint(Scintilla::Surface*, Scintilla::PRectangle) + 126
10 com.sun.Scintilla 0x00000001000eac0e Scintilla::ScintillaCocoa::SyncPaint(void*, Scintilla::PRectangle) + 186
11 com.sun.Scintilla 0x00000001000eb38d Scintilla::ScintillaCocoa::Draw(CGRect, CGContext*) + 33
12 com.sun.Scintilla 0x00000001000ec2cb -[InnerView drawRect:] + 136

Discussion

  • Neil Hodgson
    Neil Hodgson
    2012-10-21

    • assigned_to: nobody --> nyamatongwe
    • status: open --> open-accepted
     
  • Neil Hodgson
    Neil Hodgson
    2012-10-24

     
    Attachments
  • Neil Hodgson
    Neil Hodgson
    2012-10-24

    I can't integrate this until the new year, but this patch looks like it fixes the problem.
    The first hunk ignores everything after a // or /* when copying the preprocessor line. Its inaccurate but will fix almost all cases.
    Later hunks fix crashes with non-ASCII characters.

     
  • Morten MacFly
    Morten MacFly
    2012-11-27

    I am hit by this bug, too and I can confirm the patch fixes the issue just fine. Thanks for the work. BTW: You don't even need to put a comment after the "#if". The assert raises already, if you do something like:
    #if § //<- any non-char/number

     
  • Neil Hodgson
    Neil Hodgson
    2012-12-30

    Committed as two change sets: 4312 to stop non-ASCII crashes and 4313 for ignoring comments when evaluating expressions.

     
  • Neil Hodgson
    Neil Hodgson
    2012-12-30

    • status: open-accepted --> open-fixed
     
  • Neil Hodgson
    Neil Hodgson
    2013-01-17

    • status: open-fixed --> closed-fixed