diff options
author | Zufu Liu <unknown> | 2022-01-22 13:41:15 +1100 |
---|---|---|
committer | Zufu Liu <unknown> | 2022-01-22 13:41:15 +1100 |
commit | 715a474013efcbe331ec184bf295138a7194004e (patch) | |
tree | 88d1146aeb4ca7f0fdd6b22874f8f0827cc90f5f /src/Editor.cxx | |
parent | a3fff53a48e63064b14f7a1842b20f260bc5a9bc (diff) | |
download | scintilla-mirror-715a474013efcbe331ec184bf295138a7194004e.tar.gz |
Feature [feature-requests:#1422] Minor improvements to line layout and wrapping.
May avoid some small costs and be clearer.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 24 |
1 files changed, 15 insertions, 9 deletions
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); } |