Skip to content

Commit 412df74

Browse files
committed
some small tweaks to the highlighting code
1 parent 12ba791 commit 412df74

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/Highlight.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ TextCursor ParseBufferRange(const HighlightData *pass1Patterns, const std::uniqu
534534
if (endParse > modEnd) {
535535
if (beginSafety > modEnd) {
536536
prev_char = GetPrevChar(buf, beginSafety);
537+
ctx.prev_char = &prev_char;
537538
PassTwoParseString(
538539
&pass2Patterns[0],
539540
string,
@@ -546,6 +547,7 @@ TextCursor ParseBufferRange(const HighlightData *pass1Patterns, const std::uniqu
546547
startPass2Safety = std::max(beginSafety, BackwardOneContext(buf, contextRequirements, modEnd));
547548

548549
prev_char = GetPrevChar(buf, startPass2Safety);
550+
ctx.prev_char = &prev_char;
549551
PassTwoParseString(
550552
&pass2Patterns[0],
551553
&string[startPass2Safety - beginSafety],
@@ -767,28 +769,29 @@ void IncrementalReparse(const std::unique_ptr<WindowHighlightData> &highlightDat
767769
startPattern = &pass1Patterns[0];
768770
}
769771

770-
const TextCursor endAt = ParseBufferRange(startPattern, pass2Patterns, buf, styleBuf, context, beginParse, endParse);
772+
const TextCursor endAt = ParseBufferRange(startPattern, pass2Patterns, buf, styleBuf, context, beginParse, endParse);
773+
const TextCursor lastModInBuf = LastModified(styleBuf);
771774

772775
/* If parse completed at this level, move one style up in the
773776
hierarchy and start again from where the previous parse left off. */
774777
if (endAt < endParse) {
775778
beginParse = endAt;
776-
endParse = ForwardOneContext(buf, context, std::max(endAt, std::max(LastModified(styleBuf), lastMod)));
779+
endParse = ForwardOneContext(buf, context, std::max(endAt, std::max(lastModInBuf, lastMod)));
777780
if (IsPlain(parseInStyle)) {
778781
qCritical("NEdit: internal error: incr. reparse fell short");
779782
return;
780783
}
781784
parseInStyle = ParentStyleOf(parentStyles, parseInStyle);
782785

783786
// One context distance beyond last style changed means we're done
784-
} else if (LastModified(styleBuf) <= lastMod) {
787+
} else if (lastModInBuf <= lastMod) {
785788
return;
786789

787790
/* Styles are changing beyond the modification, continue extending
788791
the end of the parse range by powers of 2 * ReparseChunkSize and
789792
reparse until nothing changes */
790793
} else {
791-
lastMod = LastModified(styleBuf);
794+
lastMod = lastModInBuf;
792795
endParse = std::min(buf->BufEndOfBuffer(), ForwardOneContext(buf, context, lastMod) + (ReparseChunkSize << nPasses));
793796
}
794797
}

0 commit comments

Comments
 (0)