diff options
-rw-r--r-- | src/EditView.cxx | 5 | ||||
-rw-r--r-- | src/EditView.h | 2 | ||||
-rw-r--r-- | src/Editor.cxx | 24 | ||||
-rw-r--r-- | src/PositionCache.cxx | 3 | ||||
-rw-r--r-- | src/PositionCache.h | 5 |
5 files changed, 21 insertions, 18 deletions
diff --git a/src/EditView.cxx b/src/EditView.cxx index 527b829bf..ca78f9bad 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -462,7 +462,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt // Layout the line, determining the position of each character, // with an extra element at the end for the end of the line. - ll->positions[0] = 0; + std::fill(&ll->positions[0], &ll->positions[lineLength + 1], 0.0); bool lastSegItalics = false; BreakFinder bfLayout(ll, nullptr, Range(0, numCharsInLine), posLineStart, 0, BreakFinder::BreakFor::Text, model.pdoc, &model.reprs, nullptr); @@ -470,7 +470,6 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt const TextSegment ts = bfLayout.Next(); - std::fill(&ll->positions[ts.start + 1], &ll->positions[ts.end() + 1], 0.0f); if (vstyle.styles[ll->styles[ts.start]].visible) { if (ts.representation) { XYPOSITION representationWidth = vstyle.controlCharWidth; @@ -510,7 +509,7 @@ void EditView::LayoutLine(const EditModel &model, Surface *surface, const ViewSt lastSegItalics = (!ts.representation) && ((ll->chars[ts.end() - 1] != ' ') && vstyle.styles[ll->styles[ts.start]].italic); } - for (Sci::Position posToIncrease = ts.start + 1; posToIncrease <= ts.end(); posToIncrease++) { + for (int posToIncrease = ts.start + 1; posToIncrease <= ts.end(); posToIncrease++) { ll->positions[posToIncrease] += ll->positions[ts.start]; } } diff --git a/src/EditView.h b/src/EditView.h index e2101d745..c9364ad30 100644 --- a/src/EditView.h +++ b/src/EditView.h @@ -115,7 +115,7 @@ public: std::shared_ptr<LineLayout> RetrieveLineLayout(Sci::Line lineNumber, const EditModel &model); void LayoutLine(const EditModel &model, Surface *surface, const ViewStyle &vstyle, - LineLayout *ll, int width = LineLayout::wrapWidthInfinite); + LineLayout *ll, int width); static void UpdateBidiData(const EditModel &model, const ViewStyle &vstyle, LineLayout *ll); diff --git a/src/Editor.cxx b/src/Editor.cxx index 838f1830e..342e7de1c 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1500,8 +1500,10 @@ bool Editor::WrapOneLine(Surface *surface, Sci::Line lineToWrap) { view.LayoutLine(*this, surface, vs, ll.get(), wrapWidth); linesWrapped = ll->lines; } - return pcs->SetHeight(lineToWrap, linesWrapped + - ((vs.annotationVisible != AnnotationVisible::Hidden) ? pdoc->AnnotationLines(lineToWrap) : 0)); + if (vs.annotationVisible != AnnotationVisible::Hidden) { + linesWrapped += pdoc->AnnotationLines(lineToWrap); + } + return pcs->SetHeight(lineToWrap, linesWrapped); } // Perform wrapping for a subset of the lines needing wrapping. @@ -1516,8 +1518,11 @@ bool Editor::WrapLines(WrapScope ws) { if (wrapWidth != LineLayout::wrapWidthInfinite) { wrapWidth = LineLayout::wrapWidthInfinite; for (Sci::Line lineDoc = 0; lineDoc < pdoc->LinesTotal(); lineDoc++) { - pcs->SetHeight(lineDoc, 1 + - ((vs.annotationVisible != AnnotationVisible::Hidden) ? pdoc->AnnotationLines(lineDoc) : 0)); + int linesWrapped = 1; + if (vs.annotationVisible != AnnotationVisible::Hidden) { + linesWrapped += pdoc->AnnotationLines(lineDoc); + } + pcs->SetHeight(lineDoc, linesWrapped); } wrapOccurred = true; } @@ -1934,6 +1939,7 @@ void Editor::InsertCharacter(std::string_view sv, CharacterSource charSource) { return; } FilterSelections(); + bool wrapOccurred = false; { UndoGroup ug(pdoc, (sel.Count() > 1) || !sel.Empty() || inOverstrike); @@ -1981,17 +1987,17 @@ void Editor::InsertCharacter(std::string_view sv, CharacterSource charSource) { AutoSurface surface(this); if (surface) { if (WrapOneLine(surface, pdoc->SciLineFromPosition(positionInsert))) { - SetScrollBars(); - SetVerticalScrollPos(); - Redraw(); + wrapOccurred = true; } } } } } } - if (Wrapping()) { + if (wrapOccurred) { SetScrollBars(); + SetVerticalScrollPos(); + Redraw(); } ThinRectangularRange(); // If in wrap mode rewrap current line so EnsureCaretVisible has accurate information @@ -2944,8 +2950,8 @@ void Editor::PageMove(int direction, Selection::SelTypes selt, bool stuttered) { if (topLineNew != topLine) { SetTopLine(topLineNew); MovePositionTo(newPos, selt); - Redraw(); SetVerticalScrollPos(); + Redraw(); } else { MovePositionTo(newPos, selt); } diff --git a/src/PositionCache.cxx b/src/PositionCache.cxx index deee4c262..4025ec651 100644 --- a/src/PositionCache.cxx +++ b/src/PositionCache.cxx @@ -661,11 +661,10 @@ void BreakFinder::Insert(Sci::Position val) { } } -BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_, +BreakFinder::BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart, XYPOSITION xStart, BreakFor breakFor, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw) : ll(ll_), lineRange(lineRange_), - posLineStart(posLineStart_), nextBreak(static_cast<int>(lineRange_.start)), saeCurrentPos(0), saeNext(0), diff --git a/src/PositionCache.h b/src/PositionCache.h index e8c9293d1..aeede7058 100644 --- a/src/PositionCache.h +++ b/src/PositionCache.h @@ -212,8 +212,7 @@ struct TextSegment { // Class to break a line of text into shorter runs at sensible places. class BreakFinder { const LineLayout *ll; - Range lineRange; - Sci::Position posLineStart; + const Range lineRange; int nextBreak; std::vector<int> selAndEdge; unsigned int saeCurrentPos; @@ -235,7 +234,7 @@ public: Foreground = 2, ForegroundAndSelection = 3, }; - BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart_, + BreakFinder(const LineLayout *ll_, const Selection *psel, Range lineRange_, Sci::Position posLineStart, XYPOSITION xStart, BreakFor breakFor, const Document *pdoc_, const SpecialRepresentations *preprs_, const ViewStyle *pvsDraw); // Deleted so BreakFinder objects can not be copied. BreakFinder(const BreakFinder &) = delete; |