diff options
| author | gingerBill <bill@gingerbill.org> | 2023-06-07 22:40:46 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-06-07 22:40:46 +0100 |
| commit | 635842b322f3f12ed5a68f1dea4e3db45c0a3fee (patch) | |
| tree | 7a25fe802150bf0d21c49766d2fc3fe558d7fa97 /core | |
| parent | 7dc09ed4501d0a7b256a05e6467cd86a262367ae (diff) | |
Add more text packages to `examples/all`
Diffstat (limited to 'core')
| -rw-r--r-- | core/text/edit/text_edit.odin | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/text/edit/text_edit.odin b/core/text/edit/text_edit.odin index c49a5d0d1..8520ba674 100644 --- a/core/text/edit/text_edit.odin +++ b/core/text/edit/text_edit.odin @@ -113,15 +113,16 @@ set_text :: proc(s: ^State, text: string) { } -undo_state_push :: proc(s: ^State, undo: ^[dynamic]^Undo_State) { +undo_state_push :: proc(s: ^State, undo: ^[dynamic]^Undo_State) -> mem.Allocator_Error { text := string(s.builder.buf[:]) - item := (^Undo_State)(mem.alloc(size_of(Undo_State) + len(text), align_of(Undo_State), s.undo_text_allocator)) + item := (^Undo_State)(mem.alloc(size_of(Undo_State) + len(text), align_of(Undo_State), s.undo_text_allocator) or_return) item.selection = s.selection item.len = len(text) #no_bounds_check { runtime.copy(item.text[:len(text)], text) } - append(undo, item) + append(undo, item) or_return + return nil } undo :: proc(s: ^State, undo, redo: ^[dynamic]^Undo_State) { |