monaco-editor

How to enable "Use Regular Expressions" option on the Find Widget in Monaco Editor


Is there a way to programmatically select the "Use Regular Expressions" on the Find Widget in Monaco?

enter image description here

UPDATE: I was able to find a hacky solution by calling the setRegex() method on the findWidget but I would love to use only the public API:

var findWidget = this._editor.overlayWidgets['editor.contrib.findWidget'];
if (findWidget) {
    findWidget.widget._findInput.setRegex(true);
}

Solution

  • It turns out there's a method already:

    controller = editor.getContribution('editor.contrib.findController');
    controller.toggleRegex();
    

    Answer was provided by @brijeshb42 in this issue: https://github.com/Microsoft/monaco-editor/issues/958#issuecomment-408069435