summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-02-21 16:14:10 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-02-21 16:14:10 -0500
commit37ce64c167e12c0d652442b2ff3deb9327d1317d (patch)
tree8d6ef23080e635955529ef3a851d7d33a53230be /buffer.c
parent617907fb4731d67f6e7aca17b9dd7881f2093aad (diff)
generalized selector code seems to work, fix buffer_set_line_len memory leak
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/buffer.c b/buffer.c
index 776c9dd..0bf78d2 100644
--- a/buffer.c
+++ b/buffer.c
@@ -558,7 +558,7 @@ static Status buffer_line_set_len(TextBuffer *buffer, Line *line, u32 new_len) {
line->str = new_str;
}
}
- } else if (line->len == 0) {
+ } else if (line->len == 0 && new_len > 0) {
// start by allocating 8 code points
line->str = buffer_malloc(buffer, 8 * sizeof *line->str);
if (!line->str) {
@@ -1616,6 +1616,10 @@ void buffer_insert_utf8_at_cursor(TextBuffer *buffer, char const *utf8) {
// insert newline at cursor and auto-indent
void buffer_newline(TextBuffer *buffer) {
+ if (buffer->is_line_buffer) {
+ buffer->line_buffer_submitted = true;
+ return;
+ }
Settings const *settings = buffer_settings(buffer);
BufferPos cursor_pos = buffer->cursor_pos;
String32 line = buffer_get_line(buffer, cursor_pos.line);