iocave / monkey-patch

Inject custom javascript into vscode
MIT License
153 stars 17 forks source link

Make `promptRestart()` public. #4

Open seivan opened 4 years ago

seivan commented 4 years ago

I know it's a hacky way, and it seems to have a bug where the restart prompt pops up twice, and doesn't actually restart. It only restarts when you close the window, at least on macOS.

But it would nice not to have to replicate https://github.com/iocave/monkey-patch/blob/6eb5d64909650aee48da752965ffb921cc768e9e/src/extension.ts#L172 this in extensions using monkey-patch - for future updates where this can be fixed to something better.

knopp commented 4 years ago

It is indeed broken right now. I haven't had time to investigate why it stopped working yet.

seivan commented 4 years ago

@knopp Well, the way I use it, is just press restart twice and close the window and that seems to do the trick. Aside from that it would be nice if the extension itself offered a way to trigger the restart instead of having the copy the code.

knopp commented 4 years ago

I think the proper way to address this would be to somehow expose electron's app.relaunch to extension. Since we can inject code to vscode main process, this should be possible. Although I'm not sure at this point how involved would it be to extend the extension api through monkey-patching. EDIT: Or just expose relaunch as vscode command, which is probably better.

knopp commented 4 years ago

On second thought, this is not going to work. Relaunch need to be done right after patching vscode, however at that point no code has been loaded yet, so we can't expose relaunch to extensons.

dpren commented 4 years ago

Could you at least call closeWindow automatically after the second restart? I think that's the most confusing part.

If not, I would mention this quark in the customize-ui readme. I initially thought the extension didn't work.

knopp commented 4 years ago

@dpren, unfortunately that doesn't work. I tried invoking both the close window action and quit application action after the second restart prompt, but for some reason at that point they don't do anything. They do work when triggered without the restart prompt, but that just quits vscode, which is not ideal either.

HumidBrains commented 4 years ago

Got this same problem (on mac). I can't even close VS Code with cmd+q from within the app after having pressed the restart button that pops up twice and does nothing. I need to trigger the launch dock with cmd+tab, then do cmd+q from there to kill VS Code. When restarting Monkey Patch normally gets applied, but now for some reason, that stopped happening as well. Would be nice with a fix as it's truly a great extension.

seivan commented 3 years ago

@knopp My suggestion is to disable the restart button completely and just issue a warning/message/popup that the user should exit VSCode and restart again manually.

On macOS this would be the flow of: cmd-q -> open VSCode again. This should start your VSCode with the previous open windows and additional monkey patches enabled.