SamVerschueren / vscode-yo

Yeoman plugin for VS Code
MIT License
87 stars 15 forks source link

Fix issue when user pressed escape #10

Closed SamVerschueren closed 8 years ago

SamVerschueren commented 8 years ago

The plugin does not execute a new generator if the user pressed escape in the previous flow.

When the user starts a new generation and presses esc at some question, the flow is stopped. When he triggers a new generator, the environment is executed correctly on line 67, but the prompt method is not fired.

Does this have something to do with not calling the callback here?

SamVerschueren commented 8 years ago

@sindresorhus any idea?

sindresorhus commented 8 years ago

Might be related to lots of flakiness with readline in recent Node.js versions. See: https://github.com/sindresorhus/fkill-cli/issues/4#issuecomment-143963835.

SamVerschueren commented 8 years ago

It's a GUI interface (Visual Studio Code), so probably not related. Probably something regarding not correctly exiting a generator.

sindresorhus commented 8 years ago

Oh, I thought I was on a different repo...

Maybe @sboudrias would know.

SBoudrias commented 8 years ago

@SamVerschueren does it work if you just run two generators one after the other?

Might be an issue with grouped-queue being stopped or jammed waiting for an async callback.

SamVerschueren commented 8 years ago

@SBoudrias this does not work either, can only run one generator. Is this something I can fix in my code or should it be done somewhere else?

SamVerschueren commented 8 years ago

Sorry to ping you back @SBoudrias, but want this to be resolved before the public release of VS Code Extensions.

So this is not happening because the callback is not called with an answer object here: adapter.ts#L43-L53?

Something I might find interesting, is that the on('end') of the environment is not called when quiting the generator early, which happens here: yo.ts#L75.

PS. I will understand if you don't have the time right now to look into this :).

SBoudrias commented 8 years ago

@SamVerschueren yeah, I don't know how you're quitting early, but this is clearly a problem with the state not being reset clean.

Maybe you should explore alternative strategy? Like running yeoman in sub process where quitting early means killing the whole process.

david-driscoll commented 8 years ago

I would recreate the Yeoman instance, I had a similar problem with atom. Basically the yeoman environment needs to be reset. https://github.com/SamVerschueren/vscode-yo/blob/master/src/extension.ts#L9

SamVerschueren commented 8 years ago

Everyone, thanks for the input, got it working by recreating Yeoman as @david-driscoll suggested.