File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,15 +33,14 @@ pub fn format(comptime fmt: []const u8) []const u8 {
3333 // Find next '{' or '}' or end of string
3434 inline while (i < fmt .len and fmt [i ] != '{' and fmt [i ] != '}' ) : (i += 1 ) {}
3535
36- // Append text up to the next control character
37- if (start_index != i ) {
38- output = output ++ fmt [start_index .. i ];
39- }
40-
4136 // Handle escaped braces '{{' or '}}'
4237 if (i + 1 < fmt .len and fmt [i + 1 ] == fmt [i ]) {
43- output = output ++ fmt [i .. i + 1 ]; // Append a single brace
4438 i += 2 ; // Skip both braces
39+ }
40+
41+ // Append text up to the next control character
42+ if (start_index != i ) {
43+ output = output ++ fmt [start_index .. i ];
4544 continue ;
4645 }
4746
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ test "format - Background color and reset" {
3030test "format - Escaped braces" {
3131 const escaped_braces = chroma .format ("{{This}} is {green}green." );
3232
33- const expected = "{" ++ "This" ++ "} is " ++ COLOR_OPEN ++ "32m" ++ "green." ++ RESET ;
33+ const expected = "{{ " ++ "This" ++ "} } is " ++ COLOR_OPEN ++ "32m" ++ "green." ++ RESET ;
3434 try std .testing .expectEqualStrings (expected , escaped_braces );
3535}
3636
You can’t perform that action at this time.
0 commit comments