Dear community

I've been reported a problem with brace matching in Notepad2 (running
on Windows XP, using Scintilla 1.73, also tested with 1.74) which I'm
not able to track down, myself.

Given the construct below (working in HTML mode, but I've been able to
produce similar cases with other lexers):

<?php
if($expr == true)
# }
}
?>

Inserting an opening curly brace after the if() statement will
highlight the newly inserted brace along with the (incorrect)
counterpart after the #. When moving the caret and hitting the same
brace again, the highlighting is performed properly, the error occurs
only with newly added braces.

The logic of Notepad2 to handle brace highlighting is the following:

case SCN_UPDATEUI:

 iPos = SendMessage(hwnd,SCI_GETCURRENTPOS,0,0);
 chBr = (char)SendMessage(hwnd,SCI_GETCHARAT,iPos,0);
 if (StrChr("()[]{}",chBr)) {
   int iBrace2 = SendMessage(hwnd,SCI_BRACEMATCH,iPos,0);
   if (iBrace2 != -1)
     SendMessage(hwnd,SCI_BRACEHIGHLIGHT,iPos,iBrace2);
   else
     SendMessage(hwnd,SCI_BRACEBADLIGHT,iPos,0);

I feel that this problem has something to do with styling not yet
finished, as the documentation for SCI_BRACEMATCH says "A match only
occurs ... or the matching brace is beyond the end of styling". But
the color display of the example code above is always correct, just
the brace matching is wrong.

Comparing the Notepad2 code with the implementation of SciTE, I can
see that the latter also performs highlighting of the indent guide,
and does some style checks using a WindowAccessor object, but I still
don't see what I'm missing.

If somebody familiar with this problem could give me a hint how to
solve it, I'd be very grateful!

Greetings
--Florian
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to