diff options
-rw-r--r-- | src/ScintillaBase.cxx | 75 |
1 files changed, 38 insertions, 37 deletions
diff --git a/src/ScintillaBase.cxx b/src/ScintillaBase.cxx index e3aeadc25..b650d19c5 100644 --- a/src/ScintillaBase.cxx +++ b/src/ScintillaBase.cxx @@ -442,52 +442,53 @@ void ScintillaBase::SetLexerLanguage(const char *languageName) { } void ScintillaBase::Colourise(int start, int end) { - int lengthDoc = pdoc->Length(); - if (end == -1) - end = lengthDoc; - int len = end - start; - - PLATFORM_ASSERT(len >= 0); - PLATFORM_ASSERT(start + len <= lengthDoc); - - //WindowAccessor styler(wMain.GetID(), props); - DocumentAccessor styler(pdoc, props, wMain.GetID()); - - int styleStart = 0; - if (start > 0) - styleStart = styler.StyleAt(start - 1); - styler.SetCodePage(pdoc->dbcsCodePage); - - if (lexCurrent && (len > 0)) { // Should always succeed as null lexer should always be available - lexCurrent->Lex(start, len, styleStart, keyWordLists, styler); - styler.Flush(); - if (styler.GetPropertyInt("fold")) { - lexCurrent->Fold(start, len, styleStart, keyWordLists, styler); + if (!performingStyle) { + // Protect against reentrance, which may occur, for example, when + // fold points are discovered while performing styling and the folding + // code looks for child lines which may trigger styling. + performingStyle = true; + + int lengthDoc = pdoc->Length(); + if (end == -1) + end = lengthDoc; + int len = end - start; + + PLATFORM_ASSERT(len >= 0); + PLATFORM_ASSERT(start + len <= lengthDoc); + + //WindowAccessor styler(wMain.GetID(), props); + DocumentAccessor styler(pdoc, props, wMain.GetID()); + + int styleStart = 0; + if (start > 0) + styleStart = styler.StyleAt(start - 1); + styler.SetCodePage(pdoc->dbcsCodePage); + + if (lexCurrent && (len > 0)) { // Should always succeed as null lexer should always be available + lexCurrent->Lex(start, len, styleStart, keyWordLists, styler); styler.Flush(); + if (styler.GetPropertyInt("fold")) { + lexCurrent->Fold(start, len, styleStart, keyWordLists, styler); + styler.Flush(); + } } + + performingStyle = false; } } #endif void ScintillaBase::NotifyStyleToNeeded(int endStyleNeeded) { - if (!performingStyle) { - // Protect against reentrance, which may occur, for example, when - // fold points are discovered while performing styling and the folding - // code looks for child lines which may trigger styling. - performingStyle = true; #ifdef SCI_LEXER - if (lexLanguage != SCLEX_CONTAINER) { - int endStyled = WndProc(SCI_GETENDSTYLED, 0, 0); - int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0); - endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0); - Colourise(endStyled, endStyleNeeded); - performingStyle = false; - return; - } -#endif - Editor::NotifyStyleToNeeded(endStyleNeeded); - performingStyle = false; + if (lexLanguage != SCLEX_CONTAINER) { + int endStyled = WndProc(SCI_GETENDSTYLED, 0, 0); + int lineEndStyled = WndProc(SCI_LINEFROMPOSITION, endStyled, 0); + endStyled = WndProc(SCI_POSITIONFROMLINE, lineEndStyled, 0); + Colourise(endStyled, endStyleNeeded); + return; } +#endif + Editor::NotifyStyleToNeeded(endStyleNeeded); } sptr_t ScintillaBase::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { |