From ce51b6a717a32fd018fa378b3d5bb990ee2fe81e Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Sat, 3 Jan 2026 03:20:40 -0500 Subject: misc formatting changes --- main.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/main.c b/main.c index c258e7e..dc9800b 100644 --- a/main.c +++ b/main.c @@ -87,9 +87,8 @@ int ed_buf_open(Editor *e, const char *path) { Str paths = { 0 }; if (path) { paths = normalize_path(str_from_cstr(path), &e->scratch); - for (u32 i = 0; i < e->bufn; i++) { + for (u32 i = 0; i < e->bufn; i++) if (str_eql(e->buf[i].path, paths)) return i; - } } if (e->bufn == ED_BUF_MAX) return -1; @@ -140,9 +139,8 @@ void ed_init(Editor *e) { } void ed_fini(Editor *e) { - for (u32 i = 0; i < e->bufn; i++) { + for (u32 i = 0; i < e->bufn; i++) ed_buf_free(e, &e->buf[i]); - } if (e->search.s) free(e->search.s); if (e->yank.s) free(e->yank.s); arena_free(&e->scratch); @@ -151,9 +149,8 @@ void ed_fini(Editor *e) { u32 ed_buf_close(Editor *e, u32 i) { ed_buf_free(e, &e->buf[i]); - if (i + 1 < e->bufn) { + if (i + 1 < e->bufn) MOVE(&e->buf[i], &e->buf[i+1], e->bufn - (i + 1)); - } e->bufn--; return i > 0 ? i - 1 : 0; } @@ -186,8 +183,10 @@ static inline int is_space(u32 c) { } TxtLoc next_word(TxtLoc l) { - while (!at_end(l) && is_space(txt_chr(l))) l = cnext(l); - while (!at_end(l) && !is_space(txt_chr(l))) l = cnext(l); + while (!at_end(l) && is_space(txt_chr(l))) + l = cnext(l); + while (!at_end(l) && !is_space(txt_chr(l))) + l = cnext(l); return l; } @@ -1175,9 +1174,8 @@ static TxtLoc indent_dedent_lines(TxtLoc start, TxtLoc end, int n) { for (u32 j = n; j--;) start = txt_insert_c(start, '\t'); } else { - for (u32 j = n; j++;) - if (txt_byte(start) == '\t') - start = txt_delete_c(cnext(start)); + for (u32 j = n; j++ && txt_byte(start) == '\t';) + start = txt_delete_c(cnext(start)); } start = next_line_start(start); } -- cgit v1.2.3