DanielGavin / ols

Language server for Odin
MIT License
440 stars 68 forks source link

Comments at end of switch case get indented to case level #292

Open Patrolin opened 9 months ago

Patrolin commented 9 months ago

The following code

package main

import "core:fmt"

main :: proc() {
    switch (0) {
    case 1:
        fmt.println("case 1a")
        //fmt.println("case 1b")
    case:
        fmt.println("default a")
        //fmt.println("default b")
    }
}

gets formatted as

package main

import "core:fmt"

main :: proc() {
    switch (0) {
    case 1:
        fmt.println("case 1a")
    //fmt.println("case 1b")
    case:
        fmt.println("default a")
    //fmt.println("default b")
    }
}
Patrolin commented 8 months ago

Related? The following:

package main
import win "core:sys/windows"
Image :: struct {
    width, height: u16,
}
foo :: proc(image: Image) {
    imageInfo := win.BITMAPINFO {
        bmiHeader = {
            biSize = size_of(win.BITMAPINFOHEADER),
            biPlanes = 1,
            biBitCount = u16(32),
            biCompression = win.BI_RGB,
            biWidth = i32(image.width),
            biHeight = i32(image.height), // NOTE: bottom-up DIB
            // biHeight = -i32(image.height), // NOTE: top-down DIB
        },
    }
}

gets formatted as:

package main
import win "core:sys/windows"
Image :: struct {
    width, height: u16,
}
foo :: proc(image: Image) {
    imageInfo := win.BITMAPINFO {
        bmiHeader =  {
            biSize = size_of(win.BITMAPINFOHEADER),
            biPlanes = 1,
            biBitCount = u16(32),
            biCompression = win.BI_RGB,
            biWidth = i32(image.width),
            biHeight = i32(image.height),
        },// NOTE: bottom-up DIB
        // biHeight = -i32(image.height), // NOTE: top-down DIB
    }
}