Skip to content

Commit

Permalink
lsp: Fix ast error line index bug (#736)
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Egan <charlie@styra.com>
  • Loading branch information
charlieegan3 authored May 22, 2024
1 parent 2ca2df8 commit 9d148de
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/lsp/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 9d148de

Please sign in to comment.