Skip to content

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

@RedCMD

Description

@RedCMD

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions