MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add array depth tracking to print_value_colored

+5 -2
+5 -2
src/modules/io.c
··· 80 80 bool escape_next = false; 81 81 bool is_key = true; 82 82 int brace_depth = 0; 83 + int array_depth = 0; 83 84 char string_char = 0; 84 85 85 86 for (const char *p = str; *p; p++) { ··· 159 160 160 161 if (*p == ',') { 161 162 io_putc(*p, stream); 162 - is_key = (brace_depth > 0); 163 + is_key = (brace_depth > 0 && array_depth == 0); 163 164 continue; 164 165 } 165 166 166 167 if (*p == '\n') { 167 168 io_putc(*p, stream); 168 - is_key = (brace_depth > 0); 169 + is_key = (brace_depth > 0 && array_depth == 0); 169 170 continue; 170 171 } 171 172 ··· 191 192 io_puts(JSON_BRACE, stream); 192 193 io_putc(*p, stream); 193 194 io_puts(ANSI_RESET, stream); 195 + array_depth++; 194 196 is_key = false; 195 197 continue; 196 198 } ··· 199 201 io_puts(JSON_BRACE, stream); 200 202 io_putc(*p, stream); 201 203 io_puts(ANSI_RESET, stream); 204 + array_depth--; 202 205 is_key = false; 203 206 continue; 204 207 }