Skip to content

Commit

Permalink
lsp: Fix ast error line index bug
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Egan <charlie@styra.com>
  • Loading branch information
charlieegan3 committed May 22, 2024
1 parent 2ca2df8 commit de68881
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/lsp/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ func updateParse(cache *cache.Cache, uri string) (bool, error) {
diags := make([]types.Diagnostic, 0)

for _, astError := range astErrors {

Check failure on line 69 in internal/lsp/lint.go

View workflow job for this annotation

GitHub Actions / Matrix (ubuntu-latest, linux, true)

unnecessary leading newline (whitespace)
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"

Expand Down

0 comments on commit de68881

Please # to comment.