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

begin matching ending \n creates rogue \\G on every newline #237

Open
RedCMD opened this issue Aug 8, 2024 · 1 comment
Open

begin matching ending \n creates rogue \\G on every newline #237

RedCMD opened this issue Aug 8, 2024 · 1 comment

Comments

@RedCMD
Copy link

RedCMD commented Aug 8, 2024

A begin/end rule will create a \\G anchor immediately after the begin match ✅

however, if the begin rule matches the ending newline \n character
it causes it to place a \\G anchor at the beginning of every single line within the begin/end rule ❌

create a grammar with the following code

"begin": "#\n",
"end": "#",
"patterns": [
	{
		"match": "\\G.",
		"name": "invalid"
	}
]

create a file and apply the grammar

#
ab
cd
#

notice how both a and c are highlighted red ❌
image
even tho there should not be any \\G anchors there

remove the \n newline from the grammar
notice that there is now no incorrect \\G anchors ✅

TextMate Help/TextMate.md states:

\G matches end of parent rule’s begin — or end of last stacked while.

@RedCMD
Copy link
Author

RedCMD commented Sep 1, 2024

@alexdima is this directly related to #119?

I'm not sure what happens in TextMate (no Mac here)
are you able to confirm this is intentional and I am able to rely on this behaviour?

I can confirm that TextMate 2.0 does have this behaviour
and it seems it has a caching problem causing it to change depending on if the user just typed it

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

1 participant