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

Allow syntax patterns to match with the beginning of the line #860

Merged
merged 2 commits into from Mar 4, 2022

Conversation

Guldoman
Copy link
Member

@Guldoman Guldoman commented Mar 4, 2022

Before, syntax patterns that started with ^ matched even when testing part of the line.
Regexes worked because of how ^ is handled in the PCRE2 implementation we're using: when an offset > 1 is used, ^ never matches.

This PR addresses the following points:

  • Regexes now behave more like Lua patterns when using ^ with an offset > 1.
    That is, ^ matches the beginning of the string as specified by offset.
  • Syntax patterns/regexes that start with ^ are now considered only when matching the whole line.

Before, if `offset > 1` was used, the match would have failed because 
the beginning of the string was never met.

Now we force the beginning of the string to be the one specified by the 
offset.
Before, syntax patterns/regexes that started with `^` didn't have the 
desired effect of matching with the start of the line.

Now those patterns are used only when matching the whole line.
@jgmdev
Copy link
Member

jgmdev commented Mar 4, 2022

Tested and works perfectly for both patterns and regex, this should expand our options and lets us define syntax files without hacky workarounds when trying to match the beginning of lines, thanks for taking the time to fix this! Merging right away,

@jgmdev jgmdev merged commit 2f7da44 into lite-xl:master Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants