microsoft / microsoft/monaco-editor

[Bug] TextModel.findMatches throw SyntaxError: SyntaxError: Invalid regular expression: /with 8 core\(s\) and 57728 MB memory

Open
#4,319 0 comments 1 reaction 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

Example

Main issue:
Set a long search string, then call textModel.findMatches, it will throw the error.
image

Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `function hello() {
	alert('Hello world!');
}`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: "javascript",
	automaticLayout: true,
});

const searchStr = "sdfasefa"; // long string
const textModel = myEditor.getModel();
textModel.findMatches(searchStr, false, false, false, null, true, 100);
Reproduction Steps
const value = /* set from `myEditor.getModel()`: */ `function hello() {
	alert('Hello world!');
}`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: "javascript",
	automaticLayout: true,
});

const searchStr = "sdfasefa"; // long string
const textModel = myEditor.getModel();
textModel.findMatches(searchStr, false, false, false, null, true, 100);

Actual (Problematic) Behavior

Throw error due to the search string too long

Expected Behavior
  1. What is the size limitation of search string?
  2. Is it possible to return matches result 0 with more info instead of throwing an exception directly?
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

Use the linked Monaco Editor Playground example to reproduce the failure, then inspect the TextModel.findMatches entry point. Confirm that the long search string no longer throws a SyntaxError and verify the behavior against any existing coverage for this path.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.