Skip to content

Commit

Permalink
lsp: Fix Eval issue caused by missing comments
Browse files Browse the repository at this point in the history
Related StyraInc#1088

Signed-off-by: Charlie Egan <charlie@styra.com>
  • Loading branch information
charlieegan3 committed Sep 10, 2024
1 parent 0c1ef19 commit 434ec9a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func (l *LanguageServer) StartCommandWorker(ctx context.Context) { // nolint:mai
// When the first comment in the file is `regal eval: use-as-input`, the AST of that module is
// used as the input rather than the contents of input.json. This is a development feature for
// working on rules (built-in or custom), allowing querying the AST of the module directly.
if regalEvalUseAsInputComment.Match(currentModule.Comments[0].Text) {
if len(currentModule.Comments) > 0 && regalEvalUseAsInputComment.Match(currentModule.Comments[0].Text) {
bs, err := encoding.JSON().Marshal(currentModule)
if err != nil {
l.logError(fmt.Errorf("failed to marshal module: %w", err))
Expand Down

0 comments on commit 434ec9a

Please sign in to comment.