This commit is contained in:
2025-11-22 01:27:44 -08:00
parent 527759de09
commit 1b9b618e3a

15
main.c
View File

@@ -362,8 +362,6 @@ erow_update(struct erow *row)
int i = 0, j; int i = 0, j;
int tabs = 0; int tabs = 0;
int ctrl = 0; int ctrl = 0;
int rszp = 0;
int ncap = row->cap;
/* /*
* TODO(kyle): I'm not thrilled with this double-render. * TODO(kyle): I'm not thrilled with this double-render.
@@ -376,14 +374,13 @@ erow_update(struct erow *row)
} }
} }
rszp = tabs * (TAB_STOP-1) + ctrl * 3; if (row->rsize) {
if (rszp > row->cap) { free(row->render);
while (ncap < rszp) ncap = cap_growth(row->cap, rszp); row->rsize = 0;
row->render = realloc(row->render, ncap);
assert(row->render != NULL);
row->cap = ncap;
} }
row->render = NULL;
row->render = malloc(row->size + (tabs * (TAB_STOP-1)) + (ctrl * 3) + 1);
assert(row->render != NULL);
for (j = 0; j < row->size; j++) { for (j = 0; j < row->size; j++) {
if (row->line[j] == '\t') { if (row->line[j] == '\t') {