EmmyLua / IntelliJ-EmmyLua

Lua IDE/Debugger Plugin for IntelliJ IDEA
https://emmylua.github.io
Apache License 2.0
1.75k stars 294 forks source link

runconfig: arguments to lua interpreter and script separately? #94

Open karlp opened 6 years ago

karlp commented 6 years ago

I'm trying to set vbuf off for a script I'm working on, and I know I had this working before, but i've installed a clean computer, and can't figure it out... I want to run with lua-5.1, so I have the following options for the runconfig

program: lua-5.1
working directory: not relevant
entry file: full path to my script
parameters: -e "io.stdout:setvbuf 'no'"

That works for running a script with no options.

But to get options for my own script, I have it like so

program: full path to my script
working direcotry: not relevant
entry file: blank
parameters: <my own options here>

But now I get buffered IO, and the run window doesn't show any console output until the process terminates.

Any ideas/tips?

tangzx commented 6 years ago

emm... I am not familiar with that io.stdout:setvbuf 'no', Should it be added to the top of the script?

karlp commented 6 years ago

well, if I run my script (with just #!/usr/bin/lua) from the console, then I get console output as it's printed, or line buffered at least.

When I run the same script inside intellij, I get no output until the script completes, (after, in this case, ~20 seconds) then the entire output is printed in one hit. I'm just trying to get the script output window in intellij to behave better.

tangzx commented 6 years ago

ok, I'll test it

karlp commented 6 years ago

I looked into it further....

Working as expected, with lua 5.3

#!/usr/bin/lua
function sleep(n)  -- seconds
  local t0 = os.clock()
  while os.clock() - t0 <= n do end
end
print("before sleep args", ...)
sleep(3)
print("ending application")

Failing, with lua-5.1

#!/usr/bin/lua-5.1       <<<<< only difference
function sleep(n)  -- seconds
  local t0 = os.clock()
  while os.clock() - t0 <= n do end
end
print("before sleep args", ...)
sleep(3)
print("ending application")

In both cases, the intellij/emmylua run config is: program: myscript.lua entryfile: [blank] parameters: command line arguments to my script (prints with "before sleep args")