Don't draw out of bounds line numbers

This commit is contained in:
Krzosa Karol
2024-07-28 14:38:12 +02:00
parent 0569d64cc9
commit 01a0d5f05f
2 changed files with 13 additions and 1 deletions

View File

@@ -125,6 +125,18 @@ Rect2 Shrink(Rect2 result, float v) {
return result;
}
Rect2 ShrinkVertical(Rect2 result, float v) {
result.min.y += v;
result.max.y -= v;
return result;
}
Rect2 ShrinkHorizontal(Rect2 result, float v) {
result.min.x += v;
result.max.x -= v;
return result;
}
Vec2 GetMid(Rect2 r) {
Vec2 size = GetSize(r);
size.x /= 2.f;

View File

@@ -170,7 +170,7 @@ void DrawWindow(Window *window) {
SetScissor(window->line_numbers_rect);
Rect2I vlines = GetVisibleCells(window);
for (Int line = vlines.min.y; line <= vlines.max.y; line += 1) {
for (Int line = vlines.min.y; line <= visible.max.y && line >= 0 && line < buffer->line_starts.len; line += 1) {
Scratch scratch;
Vec2I pos = {0, line * FontLineSpacing};
pos.y -= view->scroll.y;