diff --git a/src/basic/math.cpp b/src/basic/math.cpp index d6d37fb..ef87001 100644 --- a/src/basic/math.cpp +++ b/src/basic/math.cpp @@ -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; diff --git a/src/text_editor/window_draw.cpp b/src/text_editor/window_draw.cpp index a31de77..9ce0af7 100644 --- a/src/text_editor/window_draw.cpp +++ b/src/text_editor/window_draw.cpp @@ -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;