actions.find not amongst supportedActions anymore
Hiding the find widget via editor.trigger('', 'actions.find') or editor.getAction('actions.find).run() stopped working with Monaco editor 0.22.0 and later versions. editor.supportedActions(); also doesn't list it anymore though it does for monaco versions older than 0.22.0 (notably 0.21.3). Has it been removed intentionally or is this just a bug? Also, I see that using the ctrl+f shortcut still triggers the action with 'actions.find' as the id and the entry in findModel.js is also still present and being registered in the findController. It just seems like it is not exposed anymore. What's the alternative if it has been removed intentionally?
Thanks in advance
monaco-editor version: 0.22.0 - 0.22.3 Browser: OS: Playground code that reproduces the issue:
var editor = monaco.editor.create(document.getElementById("container"), {
value: `console.log("where is da good ol' actions.find");`,
language: "typescript"
});
editor.trigger('', 'actions.find'); // actions.findWithSelection however works
Edit:
https://github.com/microsoft/vscode/commit/979f9f73b3d5cd55356c0117be169fb1edbfd92b introduced a new precondition (editorIsOpen) which is not set in the browser. Therefore the isSupported method of the IEditorAction returns false and the action is never executed.
invoking editor.createContextKey('editorIsOpen', true) after constructing the editor fixes it. I do however think that this should be the default for browsers.
invoking
editor.createContextKey('editorIsOpen', true)after constructing the editor fixes it. I do however think that this should be the default for browsers.
Looks like it is caused by https://github.com/microsoft/vscode/commit/979f9f73b3d5cd55356c0117be169fb1edbfd92b . It looks like the find action has as precondition a context key (editorIsOpen) that is only defined in the /workbench/ layer. That doesn't make sense to me.
@alexdima When will this be released?
Digging into this it looks like the action only triggers now if editorFocus is true in the context. As a workaround, I was able to focus the editor before triggering the action and it works, eg:
editor.focus();
editor.trigger('toggleFind', 'actions.find');
The getActiveCodeEditor implementation in StandaloneCodeServiceImpl always returns null:
getActiveCodeEditor() {
return null; // not supported in the standalone case
}
Is editor.focus(); really the way to go now or will there be a way to programmatically tell monaco that the editor is always active? I think the current behaviour makes sense for vscode but not in the context of a monaco instance run in a browser.
@alexdima
I still have this issue on 0.23.0 even with editor.createContextKey('editorIsOpen', true) while 0.22.3 works with this trick.
Hey @lramos15 it looks like you might be doing something weird with git and closing issues by accident
Just my 2 cents.
0.23 equivalent to 0.22
editor.setSelection(selection)
editor.getAction('actions.find').run();
is:
editor.setSelection(selection);
editor.focus();
editor.getAction('actions.find').run();
editor.revealLineInCenter(selection.positionLineNumber);
Don't know if the autofocus removal was intentional.