diff options
| author | WormHeamer | 2026-01-03 03:20:40 -0500 |
|---|---|---|
| committer | WormHeamer | 2026-01-03 03:20:40 -0500 |
| commit | ce51b6a717a32fd018fa378b3d5bb990ee2fe81e (patch) | |
| tree | c711c77d53726f7746fbc81976284de5bd47dc5c | |
| parent | 5ac902df729a9214ffcdf548865c64467ec80e23 (diff) | |
misc formatting changes
| -rw-r--r-- | main.c | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -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); } |
