lsp/eval: Ensure filenames use URI in print output#1647
Merged
charlieegan3 merged 1 commit intoopen-policy-agent:mainfrom Aug 7, 2025
Merged
lsp/eval: Ensure filenames use URI in print output#1647charlieegan3 merged 1 commit intoopen-policy-agent:mainfrom
charlieegan3 merged 1 commit intoopen-policy-agent:mainfrom
Conversation
anderseknert
approved these changes
Aug 7, 2025
internal/lsp/eval.go
Outdated
| h.Output[ctx.Location.File] = make(map[int][]string) | ||
| filename := ctx.Location.File | ||
| if h.FileNameBase != "" { | ||
| filename = strings.TrimSuffix(h.FileNameBase, "/") + "/" + ctx.Location.File |
Member
There was a problem hiding this comment.
Can use util.EnsureSuffix here. Added recently :)
Contributor
Author
There was a problem hiding this comment.
Ahh yeah, nearly remembered that! next time!
| policy2URI: { | ||
| 4: {"1"}, | ||
| }, | ||
| } |
Member
There was a problem hiding this comment.
Does this one item map really warrant 5 lines? lol
| }, | ||
| } | ||
|
|
||
| if diff := cmp.Diff(expectedPrintOutput, res.PrintOutput); diff != "" { |
Member
There was a problem hiding this comment.
Nice I didn't know about cmp.Diff
Contributor
Author
There was a problem hiding this comment.
it's pretty good, used it in OPA earlier too.
This is a regression fix from open-policy-agent#1638 which caused the print output to not be rendered in supported clients. Fixes open-policy-agent/vscode-opa#352 Signed-off-by: Charlie Egan <charlie@styra.com>
6690819 to
3514082
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a regression fix from #1638 which caused the print output to not be rendered in supported clients.
Fixes open-policy-agent/vscode-opa#352