diff options
author | Neil <nyamatongwe@gmail.com> | 2022-08-13 18:10:30 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2022-08-13 18:10:30 +1000 |
commit | 059594717cb36423733a0fbdee316f436d2e49a0 (patch) | |
tree | f137e2e289859092cd80f90a72007b2a4c2b48f3 /src/PositionCache.cxx | |
parent | 5a75bc307318c1cf04f66390299792b87f37ff97 (diff) | |
download | scintilla-mirror-059594717cb36423733a0fbdee316f436d2e49a0.tar.gz |
Move append of new line start into PositionCache as AddLineStart.
Diffstat (limited to 'src/PositionCache.cxx')
-rw-r--r-- | src/PositionCache.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
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<int[]> newLineStarts = std::make_unique<int[]>(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<int>(start); } void LineLayout::SetBracesHighlight(Range rangeLine, const Sci::Position braces[], |