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 | |
parent | 5a75bc307318c1cf04f66390299792b87f37ff97 (diff) | |
download | scintilla-mirror-059594717cb36423733a0fbdee316f436d2e49a0.tar.gz |
Move append of new line start into PositionCache as AddLineStart.
-rw-r--r-- | src/EditView.cxx | 3 | ||||
-rw-r--r-- | src/PositionCache.cxx | 9 | ||||
-rw-r--r-- | src/PositionCache.h | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index c4768a2a3..d59f99eb2 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -687,8 +687,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt } } lastLineStart = lastGoodBreak; - ll->lines++; - ll->SetLineStart(ll->lines, static_cast<int>(lastLineStart)); + ll->AddLineStart(lastLineStart); startOffset = ll->positions[lastLineStart]; // take into account the space for start wrap mark and indent startOffset += width - ll->wrapIndent; 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[], diff --git a/src/PositionCache.h b/src/PositionCache.h index ad6caea78..4d44f96e4 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -96,7 +96,7 @@ public: Range SubLineRange(int subLine, Scope scope) const noexcept; bool InLine(int offset, int line) const noexcept; int SubLineFromPosition(int posInLine, PointEnd pe) const noexcept; - void SetLineStart(int line, int start); + void AddLineStart(Sci::Position start); void SetBracesHighlight(Range rangeLine, const Sci::Position braces[], char bracesMatchStyle, int xHighlight, bool ignoreStyle); void RestoreBracesHighlight(Range rangeLine, const Sci::Position braces[], bool ignoreStyle); |