micro-editor / micro-editor/micro

Typescript ambiguous regexp highlighting with normal division

Open
#3,874 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug syntax
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

Image

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

  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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.