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

fix regex and sql injections in runtime/queries/rust/injections.scm #13057

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

m4rch3n1ng
Copy link
Contributor

@m4rch3n1ng m4rch3n1ng commented Mar 8, 2025

this fixes the rust injections for regex and sql by injecting the language into the (string_content) instead of the outer (raw_string_literal)/(string_literal)

additionally for the sql injections another issue was that they were being overriden by the default "rust" injections into the (token_tree) of all (macro_invocations), so this now filters out those specific macros.

i also wanted to add an injection for the json! macro, but i couldn't figure out a way to strip the leading and trailing paranthesis in the json!({}) call to make the content actually valid json, similar to nvim-treesitter/nvim-treesitter#7715, but (as far as i can tell) helix does not support the (#offset! ) directive and i couldn't figure out a way to achieve this with the (#strip! ) directive.

before:

image

after:

image

inject regex into (string_content) instead of into the entire
(raw_string_literal), and also adds the regex injections to the
RegexBuilder.
the sqlx injections did not work for two reasons: for one they were
overriden by the default default "rust" injection into the (token_tree)
of (macro_invocation)s and two, they were also injected into the entire
(raw_string_literal)/(string_literal) instead of the (string_content)
@the-mikedavis the-mikedavis added the A-language-support Area: Support for programming/text languages label Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants