Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completions: package name now suggested from any path component #869

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

anderseknert
Copy link
Member

And fix bug that would sometimes suggest "" as the package name.

Oh, and the provider is now written in Rego :)

Fixes #846
Fixes #856

And fix bug that would sometimes suggest "" as the package name.

Oh, and the provider is now written in Rego :)

Fixes #846
Fixes #856

Signed-off-by: Anders Eknert <[email protected]>
Copy link
Member

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I haven't tried it locally ⚠️

I don't suppose this would deal with directories like

foo/x-y/baz

properly, would it? I.e. Propose package foo["x-y"].baz?


abs_dir := base(input.regal.file.name)
rel_dir := trim_prefix(abs_dir, input.regal.context.workspace_root)
fix_dir := replace(replace(trim_prefix(rel_dir, ps), ".", "_"), ps, ".")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my 🙈

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heh, yeah, not sure how that could be made more clear... perhaps an extra intermediate assignment or something

@anderseknert
Copy link
Member Author

I don't suppose this would deal with directories like

That's correct. We should have some general way of rewriting refs to account for that. I was hoping someone would just fix that "keywords in refs need quoting" in OPA first, so we'd at least have one less thing to handle here 😅

@anderseknert anderseknert merged commit 2fa61d7 into main Jun 24, 2024
3 checks passed
@anderseknert anderseknert deleted the packagename-rego branch June 24, 2024 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants