Added missing 'assert' definition for TextInput

This commit is contained in:
00JCIV00 2024-03-29 20:35:54 -04:00 committed by Tim Culverhouse
parent ca0371bc44
commit 037a301bd6

View file

@ -6,6 +6,7 @@ const Window = @import("../Window.zig");
const GapBuffer = @import("gap_buffer").GapBuffer; const GapBuffer = @import("gap_buffer").GapBuffer;
const Unicode = @import("../Unicode.zig"); const Unicode = @import("../Unicode.zig");
const assert = std.debug.assert;
const log = std.log.scoped(.text_input); const log = std.log.scoped(.text_input);
const TextInput = @This(); const TextInput = @This();
@ -88,7 +89,7 @@ pub fn insertSliceAtCursor(self: *TextInput, data: []const u8) !void {
pub fn sliceToCursor(self: *TextInput, buf: []u8) []const u8 { pub fn sliceToCursor(self: *TextInput, buf: []u8) []const u8 {
const offset = self.byteOffsetToCursor(); const offset = self.byteOffsetToCursor();
assert(offset <= buf.len); // provided buf was too small assert(offset <= buf.len); // provided buf was too small
if (offset <= self.buf.items.len) { if (offset <= self.buf.items.len) {
@memcpy(buf[0..offset], self.buf.items[0..offset]); @memcpy(buf[0..offset], self.buf.items[0..offset]);