From 059594717cb36423733a0fbdee316f436d2e49a0 Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 13 Aug 2022 18:10:30 +1000 Subject: Move append of new line start into PositionCache as AddLineStart. --- src/PositionCache.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/PositionCache.cxx') diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index fc27dce77..f1298ddd4 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -187,9 +187,10 @@ int LineLayout::SubLineFromPosition(int posInLine, PointEnd pe) const noexcept { return lines - 1; } -void LineLayout::SetLineStart(int line, int start) { - if ((line >= lenLineStarts) && (line != 0)) { - const int newMaxLines = line + 20; +void LineLayout::AddLineStart(Sci::Position start) { + lines++; + if (lines >= lenLineStarts) { + const int newMaxLines = lines + 20; std::unique_ptr newLineStarts = std::make_unique(newMaxLines); if (lenLineStarts) { std::copy(lineStarts.get(), lineStarts.get() + lenLineStarts, newLineStarts.get()); @@ -197,7 +198,7 @@ void LineLayout::SetLineStart(int line, int start) { lineStarts = std::move(newLineStarts); lenLineStarts = newMaxLines; } - lineStarts[line] = start; + lineStarts[lines] = static_cast(start); } void LineLayout::SetBracesHighlight(Range rangeLine, const Sci::Position braces[], -- cgit v1.2.3