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

Snippet expanding in-word when it shouldn't #22

Closed
medwatt opened this issue Jun 25, 2020 · 3 comments
Closed

Snippet expanding in-word when it shouldn't #22

medwatt opened this issue Jun 25, 2020 · 3 comments

Comments

@medwatt
Copy link

medwatt commented Jun 25, 2020

According to your notes, "a snippet trigger will only match when the trigger is preceded by whitespace characters" unless the "i" flag is used.

The code below should expand for a1 as a_1 but shouldn't expand for item1 since the trigger is not preceded by whitespace characters.

snippet `[A-Za-z])(\d)` "auto subscript" A
``rv = m[1] + '_' + m[2]``
endsnip

It's quite easy to fix (as shown below), but I don't know this is correct behaviour ?

snippet `(?<= )([A-Za-z])(\d)` "auto subscript" A
``rv = m[1] + '_' + m[2]``
endsnip
@draivin
Copy link
Owner

draivin commented Jun 26, 2020

Those matching flags are only used when not in regex mode currently. By default regex matches receive the line up until the caret as context, unless the M flag is specified, in which case it receives multiple lines.

I will think about which behavior regex matches should have by default, if you have any thoughts please let me know.

@medwatt
Copy link
Author

medwatt commented Jun 26, 2020

Those matching flags are only used when not in regex mode currently. By default regex matches receive the line up until the caret as context, unless the M flag is specified, in which case it receives multiple lines.

I will think about which behavior regex matches should have by default, if you have any thoughts please let me know.

I think it makes sense to not include the flags for regex matches because that might interfere with the regex flags.

@draivin
Copy link
Owner

draivin commented Jul 18, 2020

Added a footnote to the README so as to make the flags behavior more clear.

@draivin draivin closed this as completed Jul 18, 2020
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