Skip to content

Add snippet stop at the end #1934

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

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

Conversation

FireChickenProductivity
Copy link
Contributor

Add a snippet stop at the end of every snippet that does not already have one there to allow exiting the snippet with "snip next".

I replaced .* with .*? in the regular expression to match the smallest possible match to better handle multiple instances of the same snippet stop with default values.

Someone should probably test this other than me as breaking snippets would not be fun.

# $value or ${value} or ${value:default}
return re.search(rf"\${variable_name}|\${{{variable_name}.*}}", body) is not None
return rf"\${variable_name}|\${{{variable_name}.*?}}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment why we need the ? a the end

@AndreasArvidsson
Copy link
Collaborator

Please test what happens if you don't have a $zero stop

@AndreasArvidsson
Copy link
Collaborator

AndreasArvidsson commented Jul 5, 2025

Feed back from the session. Instead of having a fixed replacement name we should find the highest numerical value and pick something that's larger than that.

We should probably unit test this

@nriley nriley added the needs testing Please test this and provide feedback in the PR! label Jul 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs testing Please test this and provide feedback in the PR!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants