diff --git a/internal/lsp/lint.go b/internal/lsp/lint.go index d5629384..b1371784 100644 --- a/internal/lsp/lint.go +++ b/internal/lsp/lint.go @@ -67,17 +67,16 @@ func updateParse(cache *cache.Cache, uri string) (bool, error) { diags := make([]types.Diagnostic, 0) for _, astError := range astErrors { - lineLength := 1 - - if astError.Location.Row-1 < len(lines) { - lineLength = len(lines[astError.Location.Row-1]) - } - line := astError.Location.Row - 1 if line < 0 { line = 0 } + lineLength := 1 + if line < len(lines) { + lineLength = len(lines[line]) + } + key := "regal/parse" link := "https://docs.styra.com/opa/category/rego-parse-error"