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

Boundary escapes don't work in a region #3055

Open
lenormf opened this issue Aug 15, 2019 · 3 comments
Open

Boundary escapes don't work in a region #3055

lenormf opened this issue Aug 15, 2019 · 3 comments

Comments

@lenormf
Copy link
Contributor

lenormf commented Aug 15, 2019

Consider trying to highlight $(…) scopes in a Makefile.

Steps

Declare those highlighters:

add-highlighter shared/makefile_functions group
add-highlighter shared/makefile_functions/ regex \A\$\(|\)\z 0:value

add-highlighter shared/makefile regions
add-highlighter shared/makefile/ region -recurse '\(' '\$\(' '\)' ref makefile_functions

Outcome

The opening and closing boundaries of the region ($( and the associated closing paren) remain un-highlighted.

Expected

The region's boundaries are highlighted.

It looks like using \A and \z to match the beginning and ending of the region do not work.

@mawww
Copy link
Owner

mawww commented Aug 18, 2019

This is currently not possible because we share a cache of regex matches on the buffer. This cache would not be valid anymore if \A and \z would not match the same positions depending on the region we are matching on. We would need to have a different cache per region, which might add a lot of additional regex parsing for highlighting.

It might be okay to do it, would use more memory and slow down highlighting, but it would solve this issue. I am not sure it is worth it though.

@lenormf
Copy link
Contributor Author

lenormf commented Aug 18, 2019

I'm really interested in highlighting the delimiters of a region that can be nested, if you see another way of allowing that, I'll take it!

I created this issue and #3056 because that was the intuitive way I tried to get the above scenario to work, somebody might have other ideas.

@lenormf
Copy link
Contributor Author

lenormf commented Oct 18, 2021

Another case made tricky: regions whose delimiters are in one format, while the inner data is in another.

Example:

<i18n lang="yaml">
fr:
    one: "un"
</i18n>

The region is in YAML format, but the delimiters are HTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants