From b89a4865d66ae4a5a002f98c3be9db5bc12efffc Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 17 Jan 2026 10:16:35 +1100 Subject: Hoist calculation of last style of line into function and simplify logic. --- src/EditView.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/EditView.cxx') diff --git a/src/EditView.cxx b/src/EditView.cxx index df772395e..ee2789ee6 100644 --- a/src/EditView.cxx +++ b/src/EditView.cxx @@ -935,8 +935,8 @@ void FillLineRemainder(Surface *surface, const EditModel &model, const ViewStyle const ColourOptional background = vsDraw.Background(model.GetMark(line), model.caret.active, ll->containsCaret); if (background) { surface->FillRectangleAligned(rcArea, Fill(*background)); - } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { - surface->FillRectangleAligned(rcArea, Fill(vsDraw.styles[ll->styles[ll->numCharsInLine]].back)); + } else if (vsDraw.styles[ll->LastStyle()].eolFilled) { + surface->FillRectangleAligned(rcArea, Fill(vsDraw.styles[ll->LastStyle()].back)); } else { surface->FillRectangleAligned(rcArea, Fill(vsDraw.styles[StyleDefault].back)); } @@ -1010,7 +1010,7 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle if (virtualSpace > 0.0f) { rcSegment.left = xEol + xStart; rcSegment.right = xEol + xStart + virtualSpace; - const ColourRGBA backgroundFill = background.value_or(vsDraw.styles[ll->styles[ll->numCharsInLine]].back); + const ColourRGBA backgroundFill = background.value_or(vsDraw.styles[ll->LastStyle()].back); surface->FillRectangleAligned(rcSegment, backgroundFill); if (vsDraw.selection.visible && (vsDraw.selection.layer == Layer::Base)) { const SelectionSegment virtualSpaceRange(SelectionPosition(model.pdoc->LineEnd(line)), @@ -1115,12 +1115,13 @@ void EditView::DrawEOL(Surface *surface, const EditModel &model, const ViewStyle } else { if (background) { surface->FillRectangleAligned(rcSegment, Fill(*background)); - } else if (line < model.pdoc->LinesTotal() - 1) { - surface->FillRectangleAligned(rcSegment, Fill(vsDraw.styles[ll->styles[ll->numCharsInLine]].back)); - } else if (vsDraw.styles[ll->styles[ll->numCharsInLine]].eolFilled) { - surface->FillRectangleAligned(rcSegment, Fill(vsDraw.styles[ll->styles[ll->numCharsInLine]].back)); } else { - surface->FillRectangleAligned(rcSegment, Fill(vsDraw.styles[StyleDefault].back)); + const Style &styleLast = vsDraw.styles[ll->LastStyle()]; + if ((line < model.pdoc->LinesTotal() - 1) || styleLast.eolFilled) { + surface->FillRectangleAligned(rcSegment, Fill(styleLast.back)); + } else { + surface->FillRectangleAligned(rcSegment, Fill(vsDraw.styles[StyleDefault].back)); + } } if (eolInSelection && (line < model.pdoc->LinesTotal() - 1) && (vsDraw.selection.layer != Layer::Base)) { surface->FillRectangleAligned(rcSegment, selectionBack); -- cgit v1.2.3