microsoft / microsoft/monaco-editor

[Feature Request] Positive lookbehind not working

Open
#3,441 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request tokenization
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Code
monaco.editor.defineTheme('LuaTheme', {
    colors: {},
    base: 'vs',
    inherit: true,
    rules: [
        { token: 'attribute', foreground: 'ff0000', fontStyle: 'bold' }
        ]
});

monaco.languages.setMonarchTokensProvider('lua', {
    tokenizer: {
        root: [
            [/(?<=\.)[a-zA-Z0-9]+/, 'attribute']
        ]
   } 
})

monaco.editor.create(document.getElementById('container'), {
	language: 'lua',
    theme: 'LuaTheme'
});
Reproduction Steps

No response

Actual (Problematic) Behavior

When providing the input 'test.test.test' it does not match anything.

Expected Behavior

It should match the second and third 'test'.

Additional Context

I tried the positive lookahead, which is working fine.

Contributor guide

Open the contributing guide

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 with the Monaco Editor playground example and the monaco.languages.setMonarchTokensProvider entry point shown in the issue. Reproduce the test.test.test input with the provided Lua tokenizer and compare positive lookbehind with the working lookahead case. Done means the second and third test segments receive the expected token without breaking the existing tokenizer behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
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.