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 references to wrong match group in zk-id-regexp #66

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

boyechko
Copy link
Contributor

@boyechko boyechko commented Jul 15, 2023

I ran into this accidentally when testing some different values for zk-id-regexp, which made zk-index completely inoperable, since button actions were not finding the note ID.

The docstring does not specify that the regexp should be wrapped in \\(...\\), but some code that matches against the regexp refers to match-string 1 while other instances (e.g. zk--id-at-point) reference the entire match (i.e. match-string 0). Since zk-link-regexp and zk-file-name-regexp add their own explicitly-numbered capture groups, it's best to consistently refer to the entire match when matching against zk-id-regexp.

NB: This pull request would need to be applied before pull request #68, but otherwise there shouldn't be any conflicts.

boyechko added 3 commits July 15, 2023 10:59
`zk-id-regexp` does not specify that the regexp should be wrapped in
`\\(...\\)`, but some code that matches against the regexp refers to
match-string 1 while other instances (e.g. `zk--id-at-point`) do not. Since
`zk-link-regexp` and `zk-file-name-regexp` add their own explicitly-numbered
capture groups, it's best to consistently refer to the entire match when
matching against `zk-id-regexp`.
Removing `\\(...\\)` is not strictly needed, but since both `zk-link-regexp` and
`zk-file-name-regexp` add capture groups themselves, it results in a cleaner
regexp.
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

Successfully merging this pull request may close these issues.

1 participant