microsoft / microsoft/monaco-editor

[Bug] onEnterRules fails with 'Javascript'

Open
#5,221 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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 Link

The snippet posted in https://github.com/microsoft/monaco-editor/issues/159#issuecomment-248728427 works fine as it is. However, it no longer works if the language is changed to 'javascript'.

Playground

Monaco Editor Playground Code
const value = `function hello() {
	alert('Hello world!');
}

// comment line 1
// comment line 2`;


monaco.languages.register({ id: 'mySpecialLanguage' });

monaco.editor.create(document.getElementById("container"), {
  value,
  language: 'mySpecialLanguage',
});

monaco.languages.setLanguageConfiguration('mySpecialLanguage', {
  onEnterRules: [
    {
      beforeText: /[0-9]$/,
      action: {
        indentAction: monaco.languages.IndentAction.None,
        appendText: 'hello world!'
      }
    }
  ]
});
Reproduction Steps

Change 'mySpecialLanguage' to 'javascript'

Actual (Problematic) Behavior

onEnterRules does not function with 'javascript'

Expected Behavior

onEnterRules to function with 'javascript'

Additional Context

No response

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 linked Monaco Editor Playground and reproduce the difference between the custom language and JavaScript using the provided onEnterRules snippet. Trace the language-configuration entry point for JavaScript and verify that onEnterRules executes there without changing the expected custom-language behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.