hcl
hcl copied to clipboard
Incorrect `srcRange` for files starting with a multiline comment
When a HCL file starts with a multiline comment, the SrcRange of the hclsyntax.Body starts after the multiline comment.
Test data
Example file starting with a multiline comment:
/********************************
Some comment
********************************/
data "google_project" "project" {
project_id = var.project_id
}
Example code for parsing the file:
f, _ := hclsyntax.ParseConfig(src, filename, pos)
body, _ := f.Body.(*hclsyntax.Body)
fmt.Println(body.Range())
Full example here: https://gist.github.com/dbanck/83e0e7936556eab2184d5d89e9d1feac
Expected behavior
SrcRange for the example file should be main.tf:1,1-8,1
Actual behavior
SrcRange for the example file is reported as main.tf:3,34-8,1
Any updates on this? I'll still facing this as of today.