lsp/completions: Handle hyphenated package names#1625
Merged
charlieegan3 merged 2 commits intoopen-policy-agent:mainfrom Jul 22, 2025
Merged
lsp/completions: Handle hyphenated package names#1625charlieegan3 merged 2 commits intoopen-policy-agent:mainfrom
charlieegan3 merged 2 commits intoopen-policy-agent:mainfrom
Conversation
a3034e8 to
a2b9126
Compare
anderseknert
approved these changes
Jul 21, 2025
Member
anderseknert
left a comment
There was a problem hiding this comment.
Very nice! Thanks Charlie. Hyphens are likely the most common char that requires quoting, but I think we could have this updated to support any char quoted path part.
| path := concat(".", array.slice(parts, n, len_p)) | ||
| formatted_parts := [p | | ||
| some index, part in array.slice(parts, n, len_p) | ||
| p := _format_part(part, contains(part, "-")) |
Member
There was a problem hiding this comment.
Rather than checking for -, should we not check for any character outside ascii and _? So that we can provide suggestions for any path that has special characters quoted?
| path != "" | ||
|
|
||
| # it's not valid Rego to have a hypenated first part | ||
| not startswith(path, `[""`) |
Member
There was a problem hiding this comment.
Not sure I follow here... ["" doesn't have a hyphen in it. But might want to rewrite this anyway for the change suggested above.
Contributor
Author
There was a problem hiding this comment.
Ahh, that looks like a typo, I think it was meant to be: ["
1646faf to
22972c9
Compare
added 2 commits
July 22, 2025 10:45
Fixes open-policy-agent#1391 Signed-off-by: Charlie Egan <charlie@styra.com>
Signed-off-by: Charlie Egan <charlie@styra.com>
22972c9 to
e68e37a
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.
Fixes #1391