be5invis / vscode-custom-css

Custom CSS Plugin for Visual Studio Code. Based on vscode-icon
MIT License
832 stars 58 forks source link

How to invoke vscode.commands.executeCommand? #160

Closed KnIfER closed 2 years ago

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

vfonic commented 2 years ago

I've got the same question. @be5invis do you have any JS code examples on how to use the extension?

I was able to stop the execution like this:

setInterval(() => {
  document_body_innerHTML = document.body.innerHTML
  debugger
}, 10*1000)

You need to call setInterval or setTimeout because otherwise the custom JS executes too quick, before majority of VS Code loaded.

Now from here, I'd like to execute a command on Editor blur. I can get currently focused editor like this:

[...document.querySelectorAll('.editor .editor-container .editor-instance textarea[aria-roledescription="editor"]')].find(el => el === document.activeElement)

Then I can add listener for "blur" like this:

editorEl.addEventListener('blur', (e) => console.log('lost focus ', e))

The only thing I'm missing is calling the VS Code command that I want.

Any ideas?

Thank you! 🙏