microsoft / microsoft/vscode-textmate

Add Option to Format in often used match expression parts

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

Nobody has claimed this yet.

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

Description

Languages often have patterns that reappear in multiple places, like identifiers or argument-lists.
These can have quite some length to it and may make the match-expression as a whole less readable.

To solve this you could add a top-level dict to the grammar description that contains name-regex pairs which are substituted into the requested places at runtime.

A good solution would be to add all defined helper functions as a preamble to each match in a named group with 0 repetitions like (?<Name>...){0}


Another possible solution might be PCRE's (?&name) (and (?(DEFINE)...)) syntax
this could be emulated via preprocessing of the patterns and string superstition,
this would not break any old code because (?&...) is illegal in ECMA's regex subset

If a switch to PCRE happens or native support is added you would just need to add a list of (?(DEFINE)...)s to the start of each match

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

The issue names no files, tests, or concrete entry points; begin by tracing how grammar descriptions become match expressions and where patterns are prepared at runtime. Done requires an agreed approach for reusable named pattern definitions that preserves existing grammar behavior and has verification coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.