micro-editor / micro-editor/micro
Typescript ambiguous regexp highlighting with normal division
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
In typescript (or javascript as well), regexp is part of the language and can be expressed like so
const myRe = /d(b+)d/g;
And we have the following rules to match it:
- constant: "/[^*]([^/]|(\\\\/))*[^\\\\]/[gim]*"
If you have the following
//My use case:
vec2.set(outVec, width / 2.0, height / 2.0);
//Or simply
const abc = 10 / 5 / 2;
Looks like this
Funny enough, javascript doesn't have this problem since the line is commented out. Due to issue #901
But then it got a different issue, somehow (issue #2820), which got fixed later.
A proper fix (if we want to highlight it) requires lookahead as mentioned by @zyedidia in #901 ,unless there's a way to specify a pattern that excludes that type.
@JoeKar, any thoughts?
Contributor guide
No contributing guide indexed for this repository
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
Start by locating the TypeScript/JavaScript syntax-highlighting definition and its YAML regexp rule. Reproduce the shown division examples alongside a valid regexp literal, then inspect the available matching features and related issues #901 and #2820. Done means normal division is not highlighted as a regexp while valid regexp literals remain highlighted, with relevant coverage if a test exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100