Thanks for sharing. I did a quick test, not very extensive. I can see how this could useful for when cloning someone else’s code that is all indented with spaces or when your editor decides to default to spaces instead of tabs without telling you (happened to me several times, grrr)
I know it’s a simple thing, but there was no help usage output, and when I ran the first time without a file, it just waited for input. Maybe at least output a message a file is expected and quit-out?
Input
package badcode
main :: proc() {
hello:="hello"
stuff:int
switch stuff {
case 1:
case 2:
}
}
Output
package badcode
main :: proc() {
hello:="hello"
stuff:int
switch stuff {
case 1:
case 2:
}
}
Should Be
package badcode
main :: proc() {
hello := "hello"
stuff: int
switch stuff {
case 1:
case 2:
}
}
Cannot seem to find the link at the moment, but I’ve see somewhere that case statements are meant to be on the same column as the switch.
Edit: This is the best example for switches I could find. switch-statement Nothing that suggests to use this format, but it seems to be common for Odin code.
I’ve also made a colorized and formatted tracker here: xuul tracker
When I added a tracker, I found the following leaks. It’s not a big deal for a program that runs for a short time and then quits. The memory is released at that time anyway. I found it still to be good practice to manage memory properly in all programs to gain better habits. It took me a little while, but after forcing myself to do it, now it feels second nature and initiative. Never-mind the line numbers for main.odin, they reflect my file which I added the tracker to, which shifted everything down about 8 lines.
Leaked Bytes 3/5 Allocations Not Freed
93 lucyfmt/main.odin:49:16 main
160 lucyfmt/formatter.odin:163:11 format_source
102 lucyfmt/formatter.odin:230:12 format_source