microsoft / microsoft/monaco-editor
[Bug] TextModel.findMatches throw SyntaxError: SyntaxError: Invalid regular expression: /with 8 core\(s\) and 57728 MB memory
Open
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?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Main issue:
Set a long search string, then call textModel.findMatches, it will throw the error.
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
- What is the size limitation of search string?
- Is it possible to return matches result 0 with more info instead of throwing an exception directly?
Additional Context
No response
Contributor guide
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
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