casteng / i-pascal

A free Object Pascal language plugin for IntelliJ IDEA
112 stars 33 forks source link

ReadLn processed out of order in IntelliJ IDEA #18

Closed eckofoid closed 6 years ago

eckofoid commented 6 years ago

I use the IPascal plugin to write and test console programs. In general, this has proven successful. However, "readln" and "writeln" do not behave properly for code run in the IntelliJ IDEA console. Regardless of the relative positions of these commands, readlns are collected and run early, before writeln commands are processed. Thus, it is impossible to enable user input in a logical way. However, the compiled binaries work perfectly if run in an external console (e.g., in OS X Terminal.app).

casteng commented 6 years ago

There is some buffering issue. I'm investigating it.

casteng commented 6 years ago

The problem is in output buffering which turns off if application is running in console window (IsATTY(Output) = 1). It needs solution from FPC side. In v1.50 a workaround for the issue was added as an option in running configuration. With the option a program is running through script command which emulates console for the application. It works both in Linux and OSX. It doesn't work for debugging.