microsoft / microsoft/vscode-textmate

`begin` matching ending `\n` creates rogue `\\G` on every newline

Open
#237 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
678
Forks
135
Avg merge
1d 14h
Merged PRs (30d)
2

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied TextMate grammar and four-line file, then trace the begin/end tokenization path that inserts the \G anchor after a begin match. Done means the newline-ending begin rule no longer causes \G to match at the start of each line, while the documented behavior remains intact.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.