Matching brace `%` skip comments and strings
Open
Nobody has claimed this yet.
kind/enhancement
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
Feature request
Skip comments and strings when pressing % to jump to closing parenthesis or bracket comments are parsed.
The vim plugin matchit implements this behavior by default.
Sample
Assume sample code:
1 function run(line) {
2 console.log(
3 'This is the line:',
4 // line should be 1) a string and 2) longer that 5
5 typeof line == 'string' && line.length > 5 ? line : ''
6 );
7 }
- Put cursor at end of line 2,
...log( - Press '%'
- Jumps to
1)on line 4. Expect it to jump to);on line 6
The code is a bit contrived to show the example, but there are legitimate places where this occurs.
Desired behavior
Select code, not comments!
See also
#1885
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No implementation file, test, or entry point is named. Start with the existing % matching behavior and compare it with the sample and Vim's matchit; done means comments and strings no longer affect matching, as described in the desired behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode
- Domain
- developer-experience, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100