I’m creating a simple extension that creates FIGlet text from the current selection. Logging the output in onStdout()
gives me the expected FIGlet text, however doing a replace()
in it gives me no output at all (no update in the editor, or errors in the console). Moving the replace()
outside onStdout()
works as expected, but obvisouly without the FIGlet process that was run on it.
The e
value, the edit, is only valid for the scope of the closure called as part of editor.edit()
. Process
executes its onStdout
callback asynchronously, so e
is no longer valid at that point.
The best solution would be to turn what you’re doing inside out, and move your entire call to editor.edit()
into either .onStdout()
, or .onExit()
and collect your text asynchronously.
1 Like
Thanks for the explaination. I structured it that way because I used the example here as a starting point.
This addressed my issue, and with a bit more messing around got things working. Much appreciated.