aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index b9b284e96..eb818b515 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -355,16 +355,18 @@ int Document::GetFoldParent(int line) {
}
}
-void Document::GetHighlightDelimiters(int line, HighlightDelimiter &highlightDelimiter) {
+void Document::GetHighlightDelimiters(HighlightDelimiter &highlightDelimiter, int line, int topLine, int bottomLine) {
+ int noNeedToParseBefore = Platform::Minimum(line, topLine) - 1;
+ int noNeedToParseAfter = Platform::Maximum(line, bottomLine) + 1;
int endLine = LineFromPosition(Length());
- int beginFoldBlock = -1;
+ int beginFoldBlock = noNeedToParseBefore;
int endFoldBlock = -1;
- int beginMarginCorrectlyDrawnZone = -1;
- int endMarginCorrectlyDrawnZone = endLine + 1;
+ int beginMarginCorrectlyDrawnZone = noNeedToParseBefore;
+ int endMarginCorrectlyDrawnZone = noNeedToParseAfter;
int endOfTailOfWhiteFlag = -1; //endOfTailOfWhiteFlag points the last SC_FOLDLEVELWHITEFLAG if follow a fold block. Otherwise endOfTailOfWhiteFlag points end of fold block.
int level = GetLevel(line);
int levelNumber = -1;
- int lineLookLevel = -1;
+ int lineLookLevel = 0;
int lineLookLevelNumber = -1;
int lineLook = line;
bool beginFoldBlockFound = false;
@@ -375,7 +377,7 @@ void Document::GetHighlightDelimiters(int line, HighlightDelimiter &highlightDel
/*******************************************************************************/
/* search backward (beginFoldBlock & beginMarginCorrectlyDrawnZone) */
/*******************************************************************************/
- for (endOfTailOfWhiteFlag = line; lineLook >= 0 && (!beginFoldBlockFound || !beginMarginCorrectlyDrawnZoneFound); --lineLook) {
+ for (endOfTailOfWhiteFlag = line; (lineLook > noNeedToParseBefore || (lineLookLevel & SC_FOLDLEVELWHITEFLAG)) && (!beginFoldBlockFound || !beginMarginCorrectlyDrawnZoneFound); --lineLook) {
lineLookLevel = GetLevel(lineLook);
if (levelNumber != -1) {
lineLookLevelNumber = lineLookLevel & SC_FOLDLEVELNUMBERMASK;
@@ -395,7 +397,8 @@ void Document::GetHighlightDelimiters(int line, HighlightDelimiter &highlightDel
beginMarginCorrectlyDrawnZone = lineLook - 1;
}
} else if (!beginFoldBlockFound && lineLookLevelNumber == SC_FOLDLEVELBASE) {
- beginFoldBlockFound = true; //beginFoldBlock already set to -1.
+ beginFoldBlockFound = true;
+ beginFoldBlock = -1;
}
} else if (!(lineLookLevel & SC_FOLDLEVELWHITEFLAG)) {
endOfTailOfWhiteFlag = lineLook - 1;
@@ -421,7 +424,7 @@ void Document::GetHighlightDelimiters(int line, HighlightDelimiter &highlightDel
} else {
lineLook = line;
}
- for (; lineLook <= endLine && (!endFoldBlockFound || !endMarginCorrectlyDrawnZoneFound); ++lineLook) {
+ for (; lineLook < noNeedToParseAfter && (!endFoldBlockFound || !endMarginCorrectlyDrawnZoneFound); ++lineLook) {
lineLookLevel = GetLevel(lineLook);
lineLookLevelNumber = lineLookLevel & SC_FOLDLEVELNUMBERMASK;
if (!endFoldBlockFound && !(lineLookLevel & SC_FOLDLEVELWHITEFLAG) && lineLookLevelNumber < levelNumber) {