Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executing code in current context #10

Closed
T-vK opened this issue Jul 30, 2020 · 11 comments
Closed

Executing code in current context #10

T-vK opened this issue Jul 30, 2020 · 11 comments

Comments

@T-vK
Copy link

T-vK commented Jul 30, 2020

Is there a way to execute in the current context without adding watches?
When I enter code in the log window I always get an error:
image

It would be nice if I could just run code in that window, just like I can in a browser console while debugging.

@eliba2
Copy link
Owner

eliba2 commented Jul 30, 2020

Hi, yes, use "repl" to go into repl mode where you can run commands.
Its also possible to run a single command without going into repl mode by prepending the command with "exec" (eg exec myvar).
The reason for this is the originating node-inspect project integration . By default you are in command mode (see help for the available commands).

@eliba2
Copy link
Owner

eliba2 commented Jul 30, 2020

It might be better to go repl mode by default. I'll check it out and keep this issue open.

@T-vK
Copy link
Author

T-vK commented Jul 30, 2020

Great, thank you!
One more question: Is it possible to see the error message when there is a syntax error preventing a script from starting?

For example:

image

When I run it manually outside of vim, I would get a proper error message like:

/tmp/asd/index.js:2
console.log(2
            ^

SyntaxError: missing ) after argument list
    at wrapSafe (internal/modules/cjs/loader.js:1054:16)
    at Module._compile (internal/modules/cjs/loader.js:1102:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

Instead of just Debugger connection lost.

@eliba2
Copy link
Owner

eliba2 commented Jul 30, 2020

I'm not sure; I'll have to look into this.

@eliba2
Copy link
Owner

eliba2 commented Aug 3, 2020

Recent version starts node repl by default.

@eliba2
Copy link
Owner

eliba2 commented Aug 3, 2020

When I try to execute a script with an error (similar to the one you posted above in the example), I do get the error message in the node console. I want to try and reproduce this, can you point me to the node version you have and is it vim/nvim?

@T-vK
Copy link
Author

T-vK commented Aug 3, 2020

node 12.18.2
vim 8.2

I simply have an empty folder with a single file called index.js with the following content:

console.log(1)
console.log(2
console.log(3)

In a bash (5.0.11(1)-release) console, I then open the file like this vim index.js. Then i simply Press F5 (I'm using the shortcuts from the readme).

Using the latest git version of your plugin, it looks like this:

image

So it still doesn't display the error.

@eliba2
Copy link
Owner

eliba2 commented Aug 15, 2020

I can confirm it occurs from node version 12 and on.
Its a problem with node-inspect; I'll post a question there.

@eliba2
Copy link
Owner

eliba2 commented Aug 15, 2020

nodejs/node#41792

@eliba2 eliba2 closed this as completed in d33705b Sep 3, 2020
@eliba2
Copy link
Owner

eliba2 commented Sep 3, 2020

The problem was the child process ended before it had the chance of reading final stderr messages. Fixed in node-inspect, I'll PR there is possible.

@T-vK
Copy link
Author

T-vK commented Sep 4, 2020

Thank you, I've tested it and it works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants