diff --git a/src/ui/windows/console_tab.cpp b/src/ui/windows/console_tab.cpp index b00fffe..8c72013 100644 --- a/src/ui/windows/console_tab.cpp +++ b/src/ui/windows/console_tab.cpp @@ -1064,6 +1064,8 @@ void ConsoleTab::drawVisibleLines(float padX, float lineHeight, bool hasTextFilt ImDrawList* dl = ImGui::GetWindowDrawList(); ImU32 selColor = WithAlpha(Secondary(), 80); + const float clipMinY = dl->GetClipRectMin().y; + const float clipMaxY = dl->GetClipRectMax().y; // A fold triangle clicked this frame; applied after the loop so we don't mutate the model // mid-draw. -1 = none. @@ -1165,6 +1167,15 @@ void ConsoleTab::drawVisibleLines(float padX, float lineHeight, bool hasTextFilt const char* segStart = line.text.c_str() + seg.byteStart; const char* segEnd = line.text.c_str() + seg.byteEnd; + // Row-granularity cull: a long wrapped line may extend far past the viewport, so skip + // sub-rows entirely outside the clip rect. The ordinal still advances once per sub-row + // (culled or not) so scanline parity is unchanged. + const bool rowVisible = rowY + seg.height >= clipMinY && rowY <= clipMaxY; + if (!rowVisible) { + ++scanRowOrdinal; + continue; + } + if (s_scanline_enabled && lineHeight > 0.0f) { scanline_rows_.push_back({rowY, rowY + seg.height, scanRowOrdinal}); }